-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Utilities and combinators for parsing command line options -- -- Here is a simple example of an applicative option parser: -- --
-- data Sample = Sample
-- { hello :: String
-- , quiet :: Bool }
--
-- sample :: Parser Sample
-- sample = Sample
-- <$> strOption
-- ( long "hello"
-- & metavar "TARGET"
-- & help "Target for the greeting" )
-- <*> switch
-- ( long "quiet"
-- & help "Whether to be quiet" )
--
--
-- The parser is built using applicative style starting from a set of
-- basic combinators. In this example, hello is defined as an
-- option with a String argument, while quiet is
-- a boolean flag (called switch).
--
-- A parser can be used like this:
--
-- -- greet :: Sample -> IO () -- greet (Sample h True) = putStrLn $ "Hello, " ++ h -- greet _ = return () -- -- main :: IO () -- main = execParser opts >>= greet -- where -- opts = info (helper <*> sample) -- ( fullDesc -- & progDesc "Print a greeting for TARGET" -- & header "hello - a test for optparse-applicative" ) ---- -- The greet function is the entry point of the program, while -- opts is a complete description of the program, used when -- generating a help text. The helper combinator takes any parser, -- and adds a help option to it (which always fails). -- -- The hello option in this example is mandatory (since it -- doesn't have a default value), so running the program without any -- argument will display a help text: -- --
-- hello - a test for optparse-applicative -- -- Usage: hello --hello TARGET [--quiet] -- Print a greeting for TARGET -- -- Common options: -- -h,--help Show this help text -- --hello TARGET Target for the greeting -- --quiet Whether to be quiet ---- -- containing a short usage summary, and a detailed list of options with -- descriptions. @package optparse-applicative @version 0.0.1 module Options.Applicative.Utils -- | Concatenate two strings with a space in the middle. (<+>) :: String -> String -> String -- | Concatenate strings vertically with empty lines in between. vcat :: [String] -> String -- | Display pairs of strings in a table. tabulate :: [(String, String)] -> String -- | Pad a string to a fixed size with whitespace. pad :: Int -> String -> String module Options.Applicative.Types -- | A full description for a runnable Parser for a program. data ParserInfo a ParserInfo :: Parser a -> Bool -> String -> String -> String -> Int -> ParserInfo a -- | the option parser for the program _infoParser :: ParserInfo a -> Parser a -- | whether the help text should contain full documentation _infoFullDesc :: ParserInfo a -> Bool -- | brief parser description _infoProgDesc :: ParserInfo a -> String -- | header of the full parser description _infoHeader :: ParserInfo a -> String -- | footer of the full parser description _infoFooter :: ParserInfo a -> String -- | exit code for a parser failure _infoFailureCode :: ParserInfo a -> Int infoParser :: Lens (ParserInfo a_a2dw) (Parser a_a2dw) infoFullDesc :: Lens (ParserInfo a_a2dw) Bool infoProgDesc :: Lens (ParserInfo a_a2dw) String infoHeader :: Lens (ParserInfo a_a2dw) String infoFooter :: Lens (ParserInfo a_a2dw) String infoFailureCode :: Lens (ParserInfo a_a2dw) Int -- | Specification for an individual parser option. data Option r a -- | option continuation Option :: OptReader r -> Maybe a -> Bool -> String -> String -> (r -> Maybe (Parser a)) -> Option r a -- | reader for this option _optMain :: Option r a -> OptReader r -- | default value _optDefault :: Option r a -> Maybe a -- | whether this flag is shown is the brief description _optShow :: Option r a -> Bool -- | help text for this option _optHelp :: Option r a -> String -- | metavariable for this option _optMetaVar :: Option r a -> String _optCont :: Option r a -> r -> Maybe (Parser a) data OptName OptShort :: !Char -> OptName OptLong :: !String -> OptName -- | An OptReader defines whether an option matches an command line -- argument. data OptReader a -- | option reader OptReader :: [OptName] -> (String -> Maybe a) -> OptReader a -- | flag reader FlagReader :: [OptName] -> !a -> OptReader a -- | argument reader ArgReader :: (String -> Maybe a) -> OptReader a -- | command reader CmdReader :: [String] -> (String -> Maybe (ParserInfo a)) -> OptReader a -- | A Parser a is an option parser returning a value of type -- a. data Parser a NilP :: a -> Parser a ConsP :: Option r (a -> b) -> Parser a -> Parser b data P a ParseError :: P a ParseResult :: a -> P a optMain :: Lens (Option r_a2du a_a2dv) (OptReader r_a2du) optDefault :: Lens (Option r_a2du a_a2dv) (Maybe a_a2dv) optShow :: Lens (Option r_a2du a_a2dv) Bool optHelp :: Lens (Option r_a2du a_a2dv) String optMetaVar :: Lens (Option r_a2du a_a2dv) String optCont :: Lens (Option r_a2du a_a2dv) (r_a2du -> Maybe (Parser a_a2dv)) instance Eq OptName instance Ord OptName instance Functor (Option r) instance Functor OptReader instance Functor ParserInfo instance Functor P instance Applicative P instance Monad P instance Applicative Parser instance Functor Parser module Options.Applicative.Common -- | A Parser a is an option parser returning a value of type -- a. data Parser a -- | Create a parser composed of a single option. liftOpt :: Option r a -> Parser a -- | A full description for a runnable Parser for a program. data ParserInfo a ParserInfo :: Parser a -> Bool -> String -> String -> String -> Int -> ParserInfo a -- | the option parser for the program _infoParser :: ParserInfo a -> Parser a -- | whether the help text should contain full documentation _infoFullDesc :: ParserInfo a -> Bool -- | brief parser description _infoProgDesc :: ParserInfo a -> String -- | header of the full parser description _infoHeader :: ParserInfo a -> String -- | footer of the full parser description _infoFooter :: ParserInfo a -> String -- | exit code for a parser failure _infoFailureCode :: ParserInfo a -> Int -- | The default value of a Parser. This function returns -- Nothing if any of the options don't have a default value. evalParser :: Parser a -> Maybe a -- | Apply a Parser to a command line, and return a result and -- leftover arguments. This function returns Nothing if any -- parsing error occurs, or if any options are missing and don't have a -- default value. runParser :: Parser a -> [String] -> Maybe (a, [String]) -- | Map a polymorphic function over all the options of a parser, and -- collect the results. mapParser :: (forall r x. Option r x -> b) -> Parser a -> [b] optionNames :: OptReader a -> [OptName] instance Monoid MatchResult module Options.Applicative.Builder -- | Builder for a command parser. The command modifier can be used -- to specify individual commands. subparser :: Mod CommandFields a a b -> Parser b -- | Builder for an argument parser. argument :: (String -> Maybe a) -> Mod f a a b -> Parser b -- | Builder for an argument list parser. All arguments are collected and -- returned as a list. arguments :: (String -> Maybe a) -> Mod f a [a] b -> Parser b -- | Builder for a flag parser. -- -- A flag that switches from a "default value" to an "active value" when -- encountered. For a simple boolean value, use switch instead. flag :: a -> a -> Mod FlagFields a a b -> Parser b -- | Builder for a boolean flag. -- --
-- switch = flag False True --switch :: Mod FlagFields Bool Bool a -> Parser a -- | Builder for an option with a null reader. A non-trivial reader can be -- added using the reader modifier. nullOption :: Mod OptionFields a a b -> Parser b -- | Builder for an option taking a String argument. strOption :: Mod OptionFields String String a -> Parser a -- | Builder for an option using the auto reader. option :: Read a => Mod OptionFields a a b -> Parser b -- | Specify a short name for an option. short :: HasName f => Char -> Mod f r a a -- | Specify a long name for an option. long :: HasName f => String -> Mod f r a a -- | Specify the help text for an option. help :: String -> Mod f r a a -- | Specify a default value for an option. value :: a -> Mod f r a a -- | Specify the metavariable. metavar :: String -> Mod f r a a -- | Specify the option reader. reader :: (String -> Maybe r) -> Mod OptionFields r a a -- | Hide this option. hide :: Mod f r a a -- | Create a multi-valued option. multi :: Mod f r a [a] -- | Apply a transformation to the return value of this option. -- -- This can be used, for example, to provide a default value for a -- required option, like: -- --
-- strOption -- ( transform Just -- , value Nothing ) --transform :: (a -> b) -> Mod f r a b -- | Add a command to a subparser option. command :: String -> ParserInfo r -> Mod CommandFields r a a -- | Trivial option modifier. idm :: Category hom => hom a a -- | Compose modifiers. (&) :: Category hom => hom a b -> hom b c -> hom a c -- | Option reader based on the Read type class. auto :: Read a => String -> Maybe a -- | String option reader. str :: String -> Maybe String -- | Null option reader. All arguments will fail validation. disabled :: String -> Maybe a data Mod f r a b class HasName f data OptionFields a data FlagFields a data CommandFields a -- | Modifier for ParserInfo. data InfoMod a b -- | Specify a full description for this parser. fullDesc :: InfoMod a a -- | Specify a header for this parser. header :: String -> InfoMod a a -- | Specify a short program description. progDesc :: String -> InfoMod a a -- | Specify a footer for this parser. footer :: String -> InfoMod a a -- | Specify an exit code if a parse error occurs. failureCode :: Int -> InfoMod a a -- | Create a ParserInfo given a Parser and a modifier. info :: Parser a -> InfoMod a a -> ParserInfo a instance Category InfoMod instance Category (Mod f r) instance HasName FlagFields instance HasName OptionFields module Options.Applicative.Help -- | Generate descriptions for commands. cmdDesc :: Parser a -> String -- | Generate a brief help text for a parser. briefDesc :: Parser a -> String -- | Generate a full help text for a parser. fullDesc :: Parser a -> String -- | Generate the help text for a program. parserHelpText :: ParserInfo a -> String module Options.Applicative.Extra -- | A hidden "helper" option which always fails. helper :: Parser (a -> a) -- | Run a program description. -- -- Parse command line arguments. Display help text and exit if any parse -- error occurs. execParser :: ParserInfo a -> IO a -- | A pure version execParser. execParserPure :: ParserInfo a -> [String] -> Either ParserFailure a -- | Generate option summary. usage :: Parser a -> String -> String -- | Result after a parse error. data ParserFailure ParserFailure :: (String -> String) -> ExitCode -> ParserFailure -- | Function which takes the program name as input and returns an error -- message errMessage :: ParserFailure -> String -> String -- | Exit code to use for this error errExitCode :: ParserFailure -> ExitCode module Options.Applicative