Options.Applicative.Types

optparse-applicative-0.12.1.0: Utilities and combinators for parsing command line options

Safe Haskell | Safe
Language | Haskell98

Options.Applicative.Types

Synopsis

- data ParseError
  - = ErrorMsg String
  - | InfoMsg String
  - | ShowHelpText
  - | UnknownError
  - | MissingError (OptTree (Chunk Doc))
- data ParserInfo a = ParserInfo {
  - infoParser :: Parser a
  - infoFullDesc :: Bool
  - infoProgDesc :: Chunk Doc
  - infoHeader :: Chunk Doc
  - infoFooter :: Chunk Doc
  - infoFailureCode :: Int
  - infoIntersperse :: Bool
  }
- data ParserPrefs = ParserPrefs {
  - prefMultiSuffix :: String
  - prefDisambiguate :: Bool
  - prefShowHelpOnError :: Bool
  - prefBacktrack :: Bool
  - prefColumns :: Int
  }
- data Option a = Option {
  - optMain :: OptReader a
  - optProps :: OptProperties
  }
- data OptName
  - = OptShort !Char
  - | OptLong !String
- data OptReader a
  - = OptReader [OptName] (CReader a) ParseError
  - | FlagReader [OptName] !a
  - | ArgReader (CReader a)
  - | CmdReader [String] (String -> Maybe (ParserInfo a))
- data OptProperties = OptProperties {
  - propVisibility :: OptVisibility
  - propHelp :: Chunk Doc
  - propMetaVar :: String
  - propShowDefault :: Maybe String
  }
- data OptVisibility
  - = Internal
  - | Hidden
  - | Visible
- newtype ReadM a = ReadM {
  - unReadM :: ReaderT String (Except ParseError) a
  }
- readerAsk :: ReadM String
- readerAbort :: ParseError -> ReadM a
- readerError :: String -> ReadM a
- data CReader a = CReader {
  - crCompleter :: Completer
  - crReader :: ReadM a
  }
- data Parser a
  - = NilP (Maybe a)
  - | OptP (Option a)
  - | forall x . MultP (Parser (x -> a)) (Parser x)
  - | AltP (Parser a) (Parser a)
  - | forall x . BindP (Parser x) (x -> Parser a)
- newtype ParserM r = ParserM {
  - runParserM :: forall x. (r -> Parser x) -> Parser x
  }
- newtype Completer = Completer {
  - runCompleter :: String -> IO [String]
  }
- mkCompleter :: (String -> IO [String]) -> Completer
- newtype CompletionResult = CompletionResult {
  - execCompletion :: String -> IO String
  }
- newtype ParserFailure h = ParserFailure {
  - execFailure :: String -> (h, ExitCode, Int)
  }
- data ParserResult a
  - = Success a
  - | Failure (ParserFailure ParserHelp)
  - | CompletionInvoked CompletionResult
- overFailure :: (ParserHelp -> ParserHelp) -> ParserResult a -> ParserResult a
- type Args = [String]
- data ArgPolicy
  - = SkipOpts
  - | AllowOpts
- data OptHelpInfo = OptHelpInfo {
  - hinfoMulti :: Bool
  - hinfoDefault :: Bool
  }
- data OptTree a
  - = Leaf a
  - | MultNode [OptTree a]
  - | AltNode [OptTree a]
- data ParserHelp = ParserHelp {
  - helpError :: Chunk Doc
  - helpHeader :: Chunk Doc
  - helpUsage :: Chunk Doc
  - helpBody :: Chunk Doc
  - helpFooter :: Chunk Doc
  }
- fromM :: ParserM a -> Parser a
- oneM :: Parser a -> ParserM a
- manyM :: Parser a -> ParserM [a]
- someM :: Parser a -> ParserM [a]
- optVisibility :: Option a -> OptVisibility
- optMetaVar :: Option a -> String
- optHelp :: Option a -> Chunk Doc
- optShowDefault :: Option a -> Maybe String

# Documentation

data ParseError

Constructors

ErrorMsg String |
InfoMsg String |
ShowHelpText |
UnknownError |
MissingError (OptTree (Chunk Doc)) |

Instances

Show ParseError |
Monoid ParseError |

data ParserInfo a

A full description for a runnable `Parser` for a program.

Constructors

ParserInfo |
Fields infoParser :: Parser a the option parser for the program infoFullDesc :: Bool whether the help text should contain full documentation infoProgDesc :: Chunk Doc brief parser description infoHeader :: Chunk Doc header of the full parser description infoFooter :: Chunk Doc footer of the full parser description infoFailureCode :: Int exit code for a parser failure infoIntersperse :: Bool allow regular options and flags to occur after arguments (default: True)

Instances

Functor ParserInfo |

data ParserPrefs

Global preferences for a top-level `Parser`.

Constructors

ParserPrefs |
Fields prefMultiSuffix :: String metavar suffix for multiple options prefDisambiguate :: Bool automatically disambiguate abbreviations (default: False) prefShowHelpOnError :: Bool always show help text on parse errors (default: False) prefBacktrack :: Bool backtrack to parent parser when a subcommand fails (default: True) prefColumns :: Int number of columns in the terminal, used to format the help page (default: 80)

Instances

Eq ParserPrefs |
Show ParserPrefs |

data Option a

A single option of a parser.

Constructors

Option |
Fields optMain :: OptReader a reader for this option optProps :: OptProperties properties of this option

Instances

Functor Option |
Show (Option a) |

data OptName

Constructors

OptShort !Char |
OptLong !String |

Instances

Eq OptName |
Ord OptName |
Show OptName |

data OptReader a

An `OptReader` defines whether an option matches an command line argument.

Constructors

OptReader [OptName] (CReader a) ParseError | option reader
FlagReader [OptName] !a | flag reader
ArgReader (CReader a) | argument reader
CmdReader [String] (String -> Maybe (ParserInfo a)) | command reader

Instances

Functor OptReader |

data OptProperties

Specification for an individual parser option.

Constructors

OptProperties |
Fields propVisibility :: OptVisibility whether this flag is shown is the brief description propHelp :: Chunk Doc help text for this option propMetaVar :: String metavariable for this option propShowDefault :: Maybe String what to show in the help text as the default

Instances

Show OptProperties |

data OptVisibility

Visibility of an option in the help text.

Constructors

Internal | does not appear in the help text at all
Hidden | only visible in the full description
Visible | visible both in the full and brief descriptions

Instances

Eq OptVisibility |
Ord OptVisibility |
Show OptVisibility |

newtype ReadM a

A newtype over 'ReaderT String Except', used by option readers.

Constructors

ReadM |
Fields unReadM :: ReaderT String (Except ParseError) a

Instances

Monad ReadM |
Functor ReadM |
Applicative ReadM |
Alternative ReadM |
MonadPlus ReadM |

readerAsk :: ReadM String

Return the value being read.

readerAbort :: ParseError -> ReadM a

Abort option reader by exiting with a `ParseError`.

readerError :: String -> ReadM a

Abort option reader by exiting with an error message.

data CReader a

Constructors

CReader |
Fields crCompleter :: Completer crReader :: ReadM a

Instances

Functor CReader |

data Parser a

A `Parser a` is an option parser returning a value of type `a`.

Constructors

NilP (Maybe a) |
OptP (Option a) |
forall x . MultP (Parser (x -> a)) (Parser x) |
AltP (Parser a) (Parser a) |
forall x . BindP (Parser x) (x -> Parser a) |

Instances

Functor Parser |
Applicative Parser |
Alternative Parser |

newtype ParserM r

Constructors

ParserM |
Fields runParserM :: forall x. (r -> Parser x) -> Parser x

Instances

Monad ParserM |
Functor ParserM |
Applicative ParserM |

newtype Completer

Constructors

Completer |
Fields runCompleter :: String -> IO [String]

Instances

Monoid Completer |

mkCompleter :: (String -> IO [String]) -> Completer

newtype CompletionResult

Constructors

CompletionResult |
Fields execCompletion :: String -> IO String

Instances

Show CompletionResult |

newtype ParserFailure h

Constructors

ParserFailure |
Fields execFailure :: String -> (h, ExitCode, Int)

Instances

Functor ParserFailure |
Show h => Show (ParserFailure h) |

data ParserResult a

Result of `execParserPure`.

Constructors

Success a |
Failure (ParserFailure ParserHelp) |
CompletionInvoked CompletionResult |

Instances

Monad ParserResult |
Functor ParserResult |
Applicative ParserResult |
Show a => Show (ParserResult a) |

overFailure :: (ParserHelp -> ParserHelp) -> ParserResult a -> ParserResult a

type Args = [String]

data ArgPolicy

Constructors

SkipOpts |
AllowOpts |

Instances

Eq ArgPolicy |
Show ArgPolicy |

data OptHelpInfo

Constructors

OptHelpInfo |
Fields hinfoMulti :: Bool hinfoDefault :: Bool

Instances

Eq OptHelpInfo |
Show OptHelpInfo |

data OptTree a

Constructors

Leaf a |
MultNode [OptTree a] |
AltNode [OptTree a] |

Instances

Show a => Show (OptTree a) |

data ParserHelp

Constructors

ParserHelp |
Fields helpError :: Chunk Doc helpHeader :: Chunk Doc helpUsage :: Chunk Doc helpBody :: Chunk Doc helpFooter :: Chunk Doc

Instances

Show ParserHelp |
Monoid ParserHelp |

fromM :: ParserM a -> Parser a

oneM :: Parser a -> ParserM a

manyM :: Parser a -> ParserM [a]

someM :: Parser a -> ParserM [a]

optVisibility :: Option a -> OptVisibility

optMetaVar :: Option a -> String

optHelp :: Option a -> Chunk Doc

optShowDefault :: Option a -> Maybe String