Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
ghcup-hs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
0931665782
ghcup-hs
Commits
eaafd77a
Verified
Commit
eaafd77a
authored
4 years ago
by
Julian Ospald
Browse files
Options
Downloads
Patches
Plain Diff
Add --version and --numeric-version
parent
9d9e415a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/ghcup/Main.hs
+27
-8
27 additions, 8 deletions
app/ghcup/Main.hs
ghcup.cabal
+1
-0
1 addition, 0 deletions
ghcup.cabal
lib/GHCup/Version.hs
+5
-0
5 additions, 0 deletions
lib/GHCup/Version.hs
with
33 additions
and
8 deletions
app/ghcup/Main.hs
+
27
−
8
View file @
eaafd77a
...
...
@@ -17,6 +17,7 @@ import GHCup.Platform
import
GHCup.Requirements
import
GHCup.Types
import
GHCup.Utils
import
GHCup.Utils.File
import
GHCup.Utils.Logger
import
GHCup.Utils.Prelude
import
GHCup.Version
...
...
@@ -40,6 +41,7 @@ import GHC.IO.Encoding
import
Haskus.Utils.Variant.Excepts
import
HPath
import
HPath.IO
import
Language.Haskell.TH
import
Options.Applicative
hiding
(
style
)
import
Prelude
hiding
(
appendFile
)
import
System.Console.Pretty
...
...
@@ -81,7 +83,6 @@ data Command
|
DInfo
|
Compile
CompileCommand
|
Upgrade
UpgradeOpts
Bool
|
NumericVersion
|
ToolRequirements
data
ToolVersion
=
ToolVersion
Version
...
...
@@ -213,11 +214,6 @@ com =
(
command
"debug-info"
((
\
_
->
DInfo
)
<$>
(
info
(
helper
)
(
progDesc
"Show debug info"
)))
<>
command
"numeric-version"
(
(
\
_
->
NumericVersion
)
<$>
(
info
(
helper
)
(
progDesc
"Show the numeric version"
))
)
<>
command
"tool-requirements"
(
(
\
_
->
ToolRequirements
)
...
...
@@ -518,11 +514,35 @@ upgradeOptsP =
describe_result
::
String
describe_result
=
$
(
(
LitE
.
StringL
)
<$>
runIO
(
do
CapturedProcess
{
..
}
<-
executeOut
[
rel
|
git
|]
[
"describe"
]
Nothing
case
_exitCode
of
ExitSuccess
->
pure
.
T
.
unpack
.
decUTF8Safe
$
_stdOut
ExitFailure
_
->
pure
numericVer
)
)
main
::
IO
()
main
=
do
let
versionHelp
=
infoOption
((
"The GHCup Haskell installer, version "
<>
)
$
(
head
.
lines
$
describe_result
)
)
(
long
"version"
<>
help
"Show version"
)
let
numericVersionHelp
=
infoOption
numericVer
(
long
"numeric-version"
<>
help
"Show the numeric version (for use in scripts)"
)
customExecParser
(
prefs
showHelpOnError
)
(
info
(
opts
<**>
helper
)
idm
)
customExecParser
(
prefs
showHelpOnError
)
(
info
(
opts
<**>
helper
<**>
versionHelp
<**>
numericVersionHelp
)
idm
)
>>=
\
opt
@
Options
{
..
}
->
do
let
settings
=
toSettings
opt
...
...
@@ -802,7 +822,6 @@ Check the logs at ~/.ghcup/logs and the build directory #{tmpdir} for more clues
VLeft
e
->
runLogger
(
$
(
logError
)
[
i
|
#{e}
|]
)
>>
exitFailure
NumericVersion
->
T
.
hPutStr
stdout
(
prettyPVP
ghcUpVer
)
ToolRequirements
->
(
runLogger
$
runE
@
'
[
NoCompatiblePlatform
,
DistroNotFound
...
...
This diff is collapsed.
Click to expand it.
ghcup.cabal
+
1
−
0
View file @
eaafd77a
...
...
@@ -328,6 +328,7 @@ executable ghcup
, resourcet
, string-interpolate
, table-layout
, template-haskell
, text
, uri-bytestring
, utf8-string
...
...
This diff is collapsed.
Click to expand it.
lib/GHCup/Version.hs
+
5
−
0
View file @
eaafd77a
...
...
@@ -9,9 +9,14 @@ import Data.Versions
import
URI.ByteString
import
URI.ByteString.QQ
import
qualified
Data.Text
as
T
-- | This reflects the API version of the JSON.
ghcupURL
::
URI
ghcupURL
=
[
uri
|
https://www.haskell.org/ghcup/data/ghcup-0.0.1.json
|]
ghcUpVer
::
PVP
ghcUpVer
=
[
pver
|
0.1.4
|]
numericVer
::
String
numericVer
=
T
.
unpack
.
prettyPVP
$
ghcUpVer
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment