mirror of
https://github.com/commercialhaskell/stackage.git
synced 2026-01-28 23:20:26 +01:00
Port stackage.hs to use optparse-applicative
This commit is contained in:
parent
1d2d92d221
commit
7819eea565
@ -1,16 +1,46 @@
|
|||||||
|
module Main where
|
||||||
|
|
||||||
|
import Control.Monad
|
||||||
|
import Data.Monoid
|
||||||
|
import Data.Version
|
||||||
|
import Options.Applicative
|
||||||
|
import Paths_stackage (version)
|
||||||
import Stackage.CompleteBuild
|
import Stackage.CompleteBuild
|
||||||
import System.Environment (getArgs)
|
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main =
|
||||||
args <- getArgs
|
join (execParser
|
||||||
case args of
|
(info (helpOption <*> versionOption <*> config)
|
||||||
[x] | Just y <- lookup x m -> y
|
(header "Stackage" <>
|
||||||
_ -> error $ "Expected one argument, one of: " ++ unwords (map fst m)
|
fullDesc)))
|
||||||
where
|
where helpOption =
|
||||||
m =
|
abortOption
|
||||||
[ ("nightly", completeBuild Nightly)
|
ShowHelpText
|
||||||
, ("lts-major", completeBuild $ LTS Major)
|
(long "help" <>
|
||||||
, ("lts-minor", completeBuild $ LTS Minor)
|
help "Show this help text")
|
||||||
, ("check", justCheck)
|
versionOption =
|
||||||
]
|
infoOption
|
||||||
|
("fpbuild version " ++ showVersion version)
|
||||||
|
(long "version" <>
|
||||||
|
help "Show fpbuild version")
|
||||||
|
config =
|
||||||
|
subparser (mconcat [cmnd completeBuild
|
||||||
|
(pure Nightly)
|
||||||
|
"nightly"
|
||||||
|
"Build, test and upload the Nightly snapshot"
|
||||||
|
,cmnd completeBuild
|
||||||
|
(pure (LTS Major))
|
||||||
|
"lts-major"
|
||||||
|
"Build, test and upload the LTS (major) snapshot"
|
||||||
|
,cmnd completeBuild
|
||||||
|
(pure (LTS Minor))
|
||||||
|
"lts-minor"
|
||||||
|
"Build, test and upload the LTS (minor) snapshot"
|
||||||
|
,cmnd (const justCheck)
|
||||||
|
(pure ())
|
||||||
|
"check"
|
||||||
|
"Just check that the build plan is ok"])
|
||||||
|
cmnd exec parse name desc =
|
||||||
|
(command name
|
||||||
|
(info (fmap exec parse)
|
||||||
|
(progDesc desc)))
|
||||||
|
|||||||
@ -68,6 +68,7 @@ executable stackage
|
|||||||
main-is: stackage.hs
|
main-is: stackage.hs
|
||||||
build-depends: base
|
build-depends: base
|
||||||
, stackage
|
, stackage
|
||||||
|
, optparse-applicative >= 0.11
|
||||||
ghc-options: -rtsopts -threaded -with-rtsopts=-N
|
ghc-options: -rtsopts -threaded -with-rtsopts=-N
|
||||||
|
|
||||||
test-suite spec
|
test-suite spec
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user