on 508fefe help sign in
stackage/app/stackage.hs
157 lines 5.0 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-haddock" <>
84 help "Skip generating haddock documentation")) <*>
85 fmap
86 not
87 (switch
88 (long "skip-upload" <>
89 help "Skip uploading bundle, docs, etc.")) <*>
90 switch
91 (long "enable-library-profiling" <>
92 help "Enable profiling when building") <*>
93 switch
94 (long "verbose" <> short 'v' <>
95 help "Output verbose detail about the build steps") <*>
96 switch
97 (long "skip-check" <>
98 help "Skip the check phase, and pass --allow-newer to cabal configure")
100 nightlyUploadFlags = fromString <$> strArgument
101 (metavar "DATE" <>
102 help "Date, in YYYY-MM-DD format")
104 installFlags =
105 InstallFlags <$>
106 (fmap
107 BPSBundleWeb
108 (strOption
109 (long "bundle" <>
110 metavar "URL" <>
111 help "Stackage bundle containing build plan")) <|>
112 fmap
113 (BPSFile . decodeString)
114 (strOption
115 (long "build-plan" <>
116 metavar "PATH" <>
117 help "Build-plan YAML file"))) <*>
118 fmap
119 decodeString
120 (strArgument
121 (metavar "DESTINATION-PATH" <>
122 help "Destination directory path")) <*>
123 (fmap
124 (Just . decodeString)
125 (strOption
126 (long "log-dir" <>
127 metavar "PATH" <>
128 help "Location of log files (default DESTINATION-PATH/logs)")) <|>
129 pure Nothing) <*>
130 option
131 auto
132 (long "jobs" <>
133 metavar "NUMBER" <>
134 showDefault <> value 8 <>
135 help "Number of threads") <*>
136 switch
137 (long "global" <>
138 help "Install in global package database") <*>
139 fmap
140 not
141 (switch
142 (long "skip-tests" <>
143 help "Skip build and running the test suites")) <*>
144 fmap
145 not
146 (switch
147 (long "skip-haddock" <>
148 help "Skip generating haddock documentation")) <*>
149 switch
150 (long "enable-library-profiling" <>
151 help "Enable profiling when building") <*>
152 switch
153 (long "verbose" <> short 'v' <>
154 help "Output verbose detail about the build steps") <*>
155 switch
156 (long "skip-check" <>
157 help "Skip the check phase, and pass --allow-newer to cabal configure")