Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell98 |
Synopsis
- data Parser a
- liftOpt :: Option a -> Parser a
- showOption :: OptName -> String
- data ParserInfo a = ParserInfo {
- infoParser :: Parser a
- infoFullDesc :: Bool
- infoProgDesc :: Chunk Doc
- infoHeader :: Chunk Doc
- infoFooter :: Chunk Doc
- infoFailureCode :: Int
- infoPolicy :: ArgPolicy
- data ParserPrefs = ParserPrefs {}
- runParserInfo :: MonadP m => ParserInfo a -> Args -> m a
- runParserFully :: MonadP m => ArgPolicy -> Parser a -> Args -> m a
- runParserStep :: MonadP m => ArgPolicy -> Parser a -> String -> Args -> m (Maybe (Parser a), Args)
- runParser :: MonadP m => ArgPolicy -> IsCmdStart -> Parser a -> Args -> m (a, Args)
- evalParser :: Parser a -> Maybe a
- mapParser :: (forall x. ArgumentReachability -> Option x -> b) -> Parser a -> [b]
- treeMapParser :: (forall x. ArgumentReachability -> Option x -> b) -> Parser a -> OptTree b
- optionNames :: OptReader a -> [OptName]
Option parsers
A Parser
is composed of a list of options. Several kinds of options
are supported:
- Flags: simple no-argument options. When a flag is encountered on the command line, its value is returned.
- Options: options with an argument. An option can define a reader, which converts its argument from String to the desired value, or throws a parse error if the argument does not validate correctly.
- Arguments: positional arguments, validated in the same way as option arguments.
- Commands. A command defines a completely independent sub-parser. When a command is encountered, the whole command line is passed to the corresponding parser.
A Parser a
is an option parser returning a value of type a
.
showOption :: OptName -> String Source #
Program descriptions
data ParserInfo a Source #
A full description for a runnable Parser
for a program.
ParserInfo | |
|
Instances
Functor ParserInfo Source # | |
Defined in Options.Applicative.Types fmap :: (a -> b) -> ParserInfo a -> ParserInfo b # (<$) :: a -> ParserInfo b -> ParserInfo a # |
data ParserPrefs Source #
Global preferences for a top-level Parser
.
ParserPrefs | |
|
Instances
Show ParserPrefs Source # | |
Defined in Options.Applicative.Types showsPrec :: Int -> ParserPrefs -> ShowS # show :: ParserPrefs -> String # showList :: [ParserPrefs] -> ShowS # | |
Eq ParserPrefs Source # | |
Defined in Options.Applicative.Types (==) :: ParserPrefs -> ParserPrefs -> Bool # (/=) :: ParserPrefs -> ParserPrefs -> Bool # |
Running parsers
runParserInfo :: MonadP m => ParserInfo a -> Args -> m a Source #
runParserStep :: MonadP m => ArgPolicy -> Parser a -> String -> Args -> m (Maybe (Parser a), Args) Source #
runParser :: MonadP m => ArgPolicy -> IsCmdStart -> Parser a -> Args -> m (a, Args) Source #
Apply a Parser
to a command line, and return a result and leftover
arguments. This function returns an error if any parsing error occurs, or
if any options are missing and don't have a default value.
evalParser :: Parser a -> Maybe a Source #
The default value of a Parser
. This function returns an error if any of
the options don't have a default value.
Low-level utilities
mapParser :: (forall x. ArgumentReachability -> Option x -> b) -> Parser a -> [b] Source #
Map a polymorphic function over all the options of a parser, and collect the results in a list.
treeMapParser :: (forall x. ArgumentReachability -> Option x -> b) -> Parser a -> OptTree b Source #
Like mapParser
, but collect the results in a tree structure.
optionNames :: OptReader a -> [OptName] Source #