| Safe Haskell | Safe-Infered |
|---|
Options.Applicative.Builder
- subparser :: Mod CommandFields a -> Parser a
- argument :: (String -> Maybe a) -> Mod ArgumentFields a -> Parser a
- arguments :: (String -> Maybe a) -> Mod ArgumentFields [a] -> Parser [a]
- flag :: a -> a -> Mod FlagFields a -> Parser a
- flag' :: a -> Mod FlagFields a -> Parser a
- switch :: Mod FlagFields Bool -> Parser Bool
- nullOption :: Mod OptionFields a -> Parser a
- strOption :: Mod OptionFields String -> Parser String
- option :: Read a => Mod OptionFields a -> Parser a
- short :: HasName f => Char -> Mod f a
- long :: HasName f => String -> Mod f a
- help :: String -> Mod f a
- value :: a -> Mod f a
- showDefaultWith :: (a -> String) -> Mod f a
- showDefault :: Show a => Mod f a
- metavar :: String -> Mod f a
- reader :: (String -> Maybe a) -> Mod OptionFields a
- hidden :: Mod f a
- internal :: Mod f a
- command :: String -> ParserInfo a -> Mod CommandFields a
- completeWith :: HasCompleter f => [String] -> Mod f a
- action :: HasCompleter f => String -> Mod f a
- completer :: HasCompleter f => Completer -> Mod f a
- idm :: Monoid m => m
- (&) :: Monoid m => m -> m -> m
- auto :: Read a => String -> Maybe a
- str :: String -> Maybe String
- disabled :: String -> Maybe a
- data Mod f a
- class HasName f
- class HasCompleter f
- data OptionFields a
- data FlagFields a
- data CommandFields a
- data ArgumentFields a
- data InfoMod a
- fullDesc :: InfoMod a
- briefDesc :: InfoMod a
- header :: String -> InfoMod a
- progDesc :: String -> InfoMod a
- footer :: String -> InfoMod a
- failureCode :: Int -> InfoMod a
- info :: Parser a -> InfoMod a -> ParserInfo a
- data PrefsMod
- multiSuffix :: String -> PrefsMod
- disambiguate :: PrefsMod
- prefs :: PrefsMod -> ParserPrefs
Parser builders
This module contains utility functions and combinators to create parsers for individual options.
Each parser builder takes an option modifier. A modifier can be created by composing the basic modifiers provided by this module using the Monoid operations mempty and mappend, or their aliases idm and &.
For example:
out = strOption ( long "output" & short 'o' & metavar "FILENAME" )
creates a parser for an option called "output".
subparser :: Mod CommandFields a -> Parser aSource
Builder for a command parser. The command modifier can be used to specify individual commands.
argument :: (String -> Maybe a) -> Mod ArgumentFields a -> Parser aSource
Builder for an argument parser.
arguments :: (String -> Maybe a) -> Mod ArgumentFields [a] -> Parser [a]Source
Builder for an argument list parser. All arguments are collected and returned as a list.
Note that arguments starting with are ignored. -
This parser accepts a special argument: --. When a -- is found on the command line, all following arguments are included in the result, even if they start with . -
Arguments
| :: a | default value |
| -> a | active value |
| -> Mod FlagFields a | option modifier |
| -> Parser a |
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.
Arguments
| :: a | active value |
| -> Mod FlagFields a | option modifier |
| -> Parser a |
Builder for a flag parser without a default value.
Same as flag, but with no default value. In particular, this flag will never parse successfully by itself.
It still makes sense to use it as part of a composite parser. For example
length <$> many (flag' () (short 't'))
is a parser that counts the number of -t arguments on the command line.
switch :: Mod FlagFields Bool -> Parser BoolSource
Builder for a boolean flag.
switch = flag False True
nullOption :: Mod OptionFields a -> Parser aSource
Builder for an option with a null reader. A non-trivial reader can be added using the reader modifier.
strOption :: Mod OptionFields String -> Parser StringSource
Builder for an option taking a String argument.
option :: Read a => Mod OptionFields a -> Parser aSource
Builder for an option using the auto reader.
Modifiers
showDefaultWith :: (a -> String) -> Mod f aSource
Specify a function to show the default value for an option.
showDefault :: Show a => Mod f aSource
Show the default value for this option using its Show instance.
command :: String -> ParserInfo a -> Mod CommandFields aSource
Add a command to a subparser option.
completeWith :: HasCompleter f => [String] -> Mod f aSource
Add a list of possible completion values.
action :: HasCompleter f => String -> Mod f aSource
Add a bash completion action. Common actions include file and directory. See http:www.gnu.orgsoftwarebashmanualhtml_node/Programmable-Completion-Builtins.html#Programmable-Completion-Builtins for a complete list.
completer :: HasCompleter f => Completer -> Mod f aSource
Add a completer to an argument.
A completer is a function String -> IO String which, given a partial argument, returns all possible completions for that argument.
Readers
A collection of basic Option readers.
Internals
Instances
class HasCompleter f Source
data OptionFields a Source
data FlagFields a Source
Instances
data CommandFields a Source
Instances
data ArgumentFields a Source
Instances
Builder for ParserInfo
failureCode :: Int -> InfoMod aSource
Specify an exit code if a parse error occurs.
info :: Parser a -> InfoMod a -> ParserInfo aSource
Create a ParserInfo given a Parser and a modifier.
Builder for ParserPrefs
multiSuffix :: String -> PrefsModSource
prefs :: PrefsMod -> ParserPrefsSource