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