|
4 | 4 | module Stack.Options.GhciParser where |
5 | 5 |
|
6 | 6 | import Options.Applicative |
7 | | -import Options.Applicative.Args |
| 7 | + ( Parser, completer, flag, help, idm, internal, long, metavar |
| 8 | + , strOption, switch |
| 9 | + ) |
| 10 | +import Options.Applicative.Args ( argsOption ) |
8 | 11 | import Options.Applicative.Builder.Extra |
9 | | -import Stack.Config (packagesParser) |
10 | | -import Stack.Ghci (GhciOpts (..)) |
11 | | -import Stack.Options.BuildParser (flagsParser) |
| 12 | + ( boolFlags, boolFlagsNoDefault, fileExtCompleter |
| 13 | + , textArgument, textOption |
| 14 | + ) |
| 15 | +import Stack.Config ( packagesParser ) |
| 16 | +import Stack.Ghci ( GhciOpts (..) ) |
| 17 | +import Stack.Options.BuildParser ( flagsParser ) |
12 | 18 | import Stack.Options.Completion |
| 19 | + ( ghcOptsCompleter, targetCompleter ) |
13 | 20 | import Stack.Prelude |
14 | 21 |
|
15 | 22 | -- | Parser for GHCI options |
16 | 23 | ghciOptsParser :: Parser GhciOpts |
17 | 24 | ghciOptsParser = GhciOpts |
18 | | - <$> many |
19 | | - (textArgument |
20 | | - (metavar "TARGET/FILE" <> |
21 | | - completer (targetCompleter <> fileExtCompleter [".hs", ".lhs"]) <> |
22 | | - help ("If none specified, use all local packages. " <> |
23 | | - "See https://docs.haskellstack.org/en/stable/build_command/#target-syntax for details. " <> |
24 | | - "If a path to a .hs or .lhs file is specified, it will be loaded."))) |
25 | | - <*> ((\x y -> x ++ concat y) |
26 | | - <$> flag |
27 | | - [] |
28 | | - ["-Wall", "-Werror"] |
29 | | - (long "pedantic" <> help "Turn on -Wall and -Werror") |
30 | | - <*> many (argsOption (long "ghci-options" <> |
31 | | - metavar "OPTIONS" <> |
32 | | - completer ghcOptsCompleter <> |
33 | | - help "Additional options passed to GHCi")) |
34 | | - ) |
35 | | - <*> (concat <$> many |
36 | | - (argsOption |
37 | | - (long "ghc-options" <> |
38 | | - metavar "OPTIONS" <> |
39 | | - completer ghcOptsCompleter <> |
40 | | - help "Additional options passed to both GHC and GHCi"))) |
41 | | - <*> flagsParser |
42 | | - <*> optional |
43 | | - (strOption (long "with-ghc" <> |
44 | | - metavar "GHC" <> |
45 | | - help "Use this GHC to run GHCi")) |
46 | | - <*> (not <$> boolFlags True "load" "load modules on start-up" idm) |
47 | | - <*> packagesParser |
48 | | - <*> optional |
49 | | - (textOption |
50 | | - (long "main-is" <> |
51 | | - metavar "TARGET" <> |
52 | | - completer targetCompleter <> |
53 | | - help "Specify which target should contain the main \ |
54 | | - \module to load, such as for an executable for \ |
55 | | - \test suite or benchmark.")) |
56 | | - <*> switch (long "load-local-deps" <> help "Load all local dependencies of your targets") |
57 | | - -- TODO: deprecate this? probably useless. |
58 | | - <*> switch (long "skip-intermediate-deps" <> help "Skip loading intermediate target dependencies" <> internal) |
59 | | - <*> optional (boolFlagsNoDefault "package-hiding" "package hiding" idm) |
60 | | - <*> switch (long "no-build" <> help "Don't build before launching GHCi" <> internal) |
61 | | - <*> switch (long "only-main" <> help "Only load and import the main module. If no main module, no modules will be loaded.") |
| 25 | + <$> many (textArgument |
| 26 | + ( metavar "TARGET/FILE" |
| 27 | + <> completer (targetCompleter <> fileExtCompleter [".hs", ".lhs"]) |
| 28 | + <> help "If none specified, use all local packages. See \ |
| 29 | + \https://docs.haskellstack.org/en/stable/build_command/#target-syntax \ |
| 30 | + \for details. If a path to a .hs or .lhs file is specified, it \ |
| 31 | + \will be loaded." |
| 32 | + )) |
| 33 | + <*> ( (\x y -> x ++ concat y) |
| 34 | + <$> flag |
| 35 | + [] |
| 36 | + ["-Wall", "-Werror"] |
| 37 | + ( long "pedantic" |
| 38 | + <> help "Turn on -Wall and -Werror" |
| 39 | + ) |
| 40 | + <*> many (argsOption |
| 41 | + ( long "ghci-options" |
| 42 | + <> metavar "OPTIONS" |
| 43 | + <> completer ghcOptsCompleter |
| 44 | + <> help "Additional options passed to GHCi" |
| 45 | + )) |
| 46 | + ) |
| 47 | + <*> ( concat |
| 48 | + <$> many (argsOption |
| 49 | + ( long "ghc-options" |
| 50 | + <> metavar "OPTIONS" |
| 51 | + <> completer ghcOptsCompleter |
| 52 | + <> help "Additional options passed to both GHC and GHCi" |
| 53 | + )) |
| 54 | + ) |
| 55 | + <*> flagsParser |
| 56 | + <*> optional (strOption |
| 57 | + ( long "with-ghc" |
| 58 | + <> metavar "GHC" |
| 59 | + <> help "Use this GHC to run GHCi" |
| 60 | + )) |
| 61 | + <*> ( not |
| 62 | + <$> boolFlags True |
| 63 | + "load" |
| 64 | + "load modules on start-up" |
| 65 | + idm |
| 66 | + ) |
| 67 | + <*> packagesParser |
| 68 | + <*> optional (textOption |
| 69 | + ( long "main-is" |
| 70 | + <> metavar "TARGET" |
| 71 | + <> completer targetCompleter |
| 72 | + <> help "Specify which target should contain the main module to load, \ |
| 73 | + \such as for an executable for test suite or benchmark." |
| 74 | + )) |
| 75 | + <*> switch |
| 76 | + ( long "load-local-deps" |
| 77 | + <> help "Load all local dependencies of your targets" |
| 78 | + ) |
| 79 | + -- TODO: deprecate this? probably useless. |
| 80 | + <*> switch |
| 81 | + ( long "skip-intermediate-deps" |
| 82 | + <> help "Skip loading intermediate target dependencies" |
| 83 | + <> internal |
| 84 | + ) |
| 85 | + <*> optional (boolFlagsNoDefault |
| 86 | + "package-hiding" |
| 87 | + "package hiding" |
| 88 | + idm) |
| 89 | + <*> switch |
| 90 | + ( long "no-build" |
| 91 | + <> help "Don't build before launching GHCi" |
| 92 | + <> internal |
| 93 | + ) |
| 94 | + <*> switch |
| 95 | + ( long "only-main" |
| 96 | + <> help "Only load and import the main module. If no main module, no \ |
| 97 | + \modules will be loaded." |
| 98 | + ) |
0 commit comments