Skip to content

Commit ffb318a

Browse files
committed
Merge pull request commercialhaskell#2037 from phadej/issue-1800
Issue 1800: Show bundled hpack version in --version
2 parents c215913 + 9e17943 commit ffb318a

3 files changed

Lines changed: 17 additions & 5 deletions

File tree

src/Options/Applicative/Complicated.hs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ complicatedOptions
3030
-> Maybe String
3131
-- ^ version string
3232
-> String
33+
-- ^ hpack numeric version, as string
34+
-> String
3335
-- ^ header
3436
-> String
3537
-- ^ program description
@@ -41,7 +43,7 @@ complicatedOptions
4143
-> EitherT b (Writer (Mod CommandFields (b,a))) ()
4244
-- ^ commands (use 'addCommand')
4345
-> IO (a,b)
44-
complicatedOptions numericVersion versionString h pd commonParser mOnFailure commandParser =
46+
complicatedOptions numericVersion versionString numericHpackVersion h pd commonParser mOnFailure commandParser =
4547
do args <- getArgs
4648
(a,(b,c)) <- case execParserPure (prefs noBacktrack) parser args of
4749
Failure _ | null args -> withArgs ["--help"] (execParser parser)
@@ -54,7 +56,7 @@ complicatedOptions numericVersion versionString h pd commonParser mOnFailure com
5456
versionOptions =
5557
case versionString of
5658
Nothing -> versionOption (showVersion numericVersion)
57-
Just s -> versionOption s <*> numericVersionOption
59+
Just s -> versionOption s <*> numericVersionOption <*> numericHpackVersionOption
5860
versionOption s =
5961
infoOption
6062
s
@@ -65,6 +67,11 @@ complicatedOptions numericVersion versionString h pd commonParser mOnFailure com
6567
(showVersion numericVersion)
6668
(long "numeric-version" <>
6769
help "Show only version number")
70+
numericHpackVersionOption =
71+
infoOption
72+
numericHpackVersion
73+
(long "hpack-numeric-version" <>
74+
help "Show only hpack's version number")
6875

6976
-- | Add a command to the options dispatcher.
7077
addCommand :: String -- ^ command string

src/main/Main.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,14 @@ versionString' = concat $ concat
116116
, [" (" ++ commitCount ++ " commits)" | commitCount /= ("1"::String) &&
117117
commitCount /= ("UNKNOWN" :: String)]
118118
, [" ", display buildArch]
119+
, [" hpack-", VERSION_hpack]
119120
]
120121
where commitCount = $gitCommitCount
121122
#else
122-
versionString' = showVersion Meta.version ++ ' ' : display buildArch
123+
versionString' =
124+
showVersion Meta.version
125+
++ ' ' : display buildArch
126+
++ " hpack" ++ VERSION_hpack
123127
#endif
124128

125129
main :: IO ()
@@ -177,6 +181,7 @@ commandLineHandler
177181
commandLineHandler progName isInterpreter = complicatedOptions
178182
Meta.version
179183
(Just versionString')
184+
VERSION_hpack
180185
"stack - The Haskell Tool Stack"
181186
""
182187
(globalOpts OuterGlobalOpts)

stack.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ nix:
99
packages:
1010
- zlib
1111
extra-deps:
12-
- path-io-1.1.0
13-
- hpack-0.10.0
12+
- hpack-0.12.0
1413
- path-0.5.7
14+
- path-io-1.1.0

0 commit comments

Comments
 (0)