forked from commercialhaskell/stack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScriptParser.hs
More file actions
33 lines (29 loc) · 973 Bytes
/
ScriptParser.hs
File metadata and controls
33 lines (29 loc) · 973 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
module Stack.Options.ScriptParser where
import Data.Monoid ((<>))
import Options.Applicative
data ScriptOpts = ScriptOpts
{ soPackages :: ![String]
, soFile :: !FilePath
, soArgs :: ![String]
, soCompile :: !ScriptExecute
}
deriving Show
data ScriptExecute
= SEInterpret
| SECompile
| SEOptimize
deriving Show
scriptOptsParser :: Parser ScriptOpts
scriptOptsParser = ScriptOpts
<$> many (strOption (long "package" <> help "Additional packages that must be installed"))
<*> strArgument (metavar "FILENAME")
<*> many (strArgument (metavar "-- ARGS (e.g. stack ghc -- X.hs -o x)"))
<*> (flag' SECompile
( long "compile"
<> help "Compile the script without optimization and run the executable"
) <|>
flag' SEOptimize
( long "optimize"
<> help "Compile the script with optimization and run the executable"
) <|>
pure SEInterpret)