on 8568f83 help sign in
stackage/app/stackage.hs
147 lines 4.6 kB history raw
1{-# LANGUAGE TupleSections #-}
3module Main where
5import Control.Monad
6import Data.Monoid
7import Data.String (fromString)
8import Data.Version
9import Options.Applicative
10import Filesystem.Path.CurrentOS (decodeString)
11import Paths_stackage (version)
12import Stackage.CompleteBuild
13import Stackage.InstallBuild
15main :: IO ()
16main =
17 join $
18 execParser $
19 info
20 (helpOption <*> versionOption <*> config)
21 (header "Stackage" <>
22 fullDesc)
23 where
24 helpOption =
25 abortOption ShowHelpText $
26 long "help" <>
27 help "Show this help text"
28 versionOption =
29 infoOption
30 ("stackage version " ++ showVersion version)
31 (long "version" <>
32 help "Show stackage version")
33 config =
34 subparser $
35 mconcat
36 [ cmnd
37 (uncurry completeBuild)
38 (fmap (Nightly, ) buildFlags)
39 "nightly"
40 "Build, test and upload the Nightly snapshot"
41 , cmnd
42 (uncurry completeBuild)
43 (fmap (LTS Major, ) buildFlags)
44 "lts-major"
45 "Build, test and upload the LTS (major) snapshot"
46 , cmnd
47 (uncurry completeBuild)
48 (fmap (LTS Minor, ) buildFlags)
49 "lts-minor"
50 "Build, test and upload the LTS (minor) snapshot"
51 , cmnd
52 justUploadNightly
53 nightlyUploadFlags
54 "upload-nightly"
55 "Upload an already-built nightly snapshot"
56 , cmnd
57 (const justCheck)
58 (pure ())
59 "check"
60 "Just check that the build plan is ok"
61 , cmnd
62 installBuild
63 installFlags
64 "install"
65 "Install a snapshot from an existing build plan"]
67 cmnd exec parse name desc =
68 command name $
69 info
70 (fmap exec (parse <**> helpOption))
71 (progDesc desc)
73 buildFlags =
74 BuildFlags <$>
75 fmap
76 not
77 (switch
78 (long "skip-tests" <>
79 help "Skip build and running the test suites")) <*>
80 fmap
81 not
82 (switch
83 (long "skip-upload" <>
84 help "Skip uploading bundle, docs, etc.")) <*>
85 switch
86 (long "enable-library-profiling" <>
87 help "Enable profiling when building") <*>
88 switch
89 (long "verbose" <> short 'v' <>
90 help "Output verbose detail about the build steps") <*>
91 switch
92 (long "skip-check" <>
93 help "Skip the check phase, and pass --allow-newer to cabal configure")
95 nightlyUploadFlags = fromString <$> strArgument
96 (metavar "DATE" <>
97 help "Date, in YYYY-MM-DD format")
99 installFlags =
100 InstallFlags <$>
101 (fmap
102 BPSBundleWeb
103 (strOption
104 (long "bundle" <>
105 metavar "URL" <>
106 help "Stackage bundle containing build plan")) <|>
107 fmap
108 (BPSFile . decodeString)
109 (strOption
110 (long "build-plan" <>
111 metavar "PATH" <>
112 help "Build-plan YAML file"))) <*>
113 fmap
114 decodeString
115 (strArgument
116 (metavar "DESTINATION-PATH" <>
117 help "Destination directory path")) <*>
118 (fmap
119 (Just . decodeString)
120 (strOption
121 (long "log-dir" <>
122 metavar "PATH" <>
123 help "Location of log files (default DESTINATION-PATH/logs)")) <|>
124 pure Nothing) <*>
125 option
126 auto
127 (long "jobs" <>
128 metavar "NUMBER" <>
129 showDefault <> value 8 <>
130 help "Number of threads") <*>
131 switch
132 (long "global" <>
133 help "Install in global package database") <*>
134 fmap
135 not
136 (switch
137 (long "skip-tests" <>
138 help "Skip build and running the test suites")) <*>
139 switch
140 (long "enable-library-profiling" <>
141 help "Enable profiling when building") <*>
142 switch
143 (long "verbose" <> short 'v' <>
144 help "Output verbose detail about the build steps") <*>
145 switch
146 (long "skip-check" <>
147 help "Skip the check phase, and pass --allow-newer to cabal configure")