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

Safe HaskellSafe
LanguageHaskell98

Options.Applicative.Types

Synopsis

Documentation

data ParserInfo a Source #

A full description for a runnable Parser for a program.

Constructors

ParserInfo 

Fields

Instances
Functor ParserInfo Source # 
Instance details

Defined in Options.Applicative.Types

Methods

fmap :: (a -> b) -> ParserInfo a -> ParserInfo b

(<$) :: a -> ParserInfo b -> ParserInfo a

data ParserPrefs Source #

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)

  • prefShowHelpOnEmpty :: Bool

    show the help text for a command or subcommand if it fails with no input (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 Source # 
Instance details

Defined in Options.Applicative.Types

Methods

(==) :: ParserPrefs -> ParserPrefs -> Bool

(/=) :: ParserPrefs -> ParserPrefs -> Bool

Show ParserPrefs Source # 
Instance details

Defined in Options.Applicative.Types

Methods

showsPrec :: Int -> ParserPrefs -> ShowS

show :: ParserPrefs -> String

showList :: [ParserPrefs] -> ShowS

data Option a Source #

A single option of a parser.

Constructors

Option 

Fields

Instances
Functor Option Source # 
Instance details

Defined in Options.Applicative.Types

Methods

fmap :: (a -> b) -> Option a -> Option b

(<$) :: a -> Option b -> Option a

Show (Option a) Source # 
Instance details

Defined in Options.Applicative.Types

Methods

showsPrec :: Int -> Option a -> ShowS

show :: Option a -> String

showList :: [Option a] -> ShowS

data OptName Source #

Constructors

OptShort !Char 
OptLong !String 
Instances
Eq OptName Source # 
Instance details

Defined in Options.Applicative.Types

Methods

(==) :: OptName -> OptName -> Bool

(/=) :: OptName -> OptName -> Bool

Ord OptName Source # 
Instance details

Defined in Options.Applicative.Types

Methods

compare :: OptName -> OptName -> Ordering

(<) :: OptName -> OptName -> Bool

(<=) :: OptName -> OptName -> Bool

(>) :: OptName -> OptName -> Bool

(>=) :: OptName -> OptName -> Bool

max :: OptName -> OptName -> OptName

min :: OptName -> OptName -> OptName

Show OptName Source # 
Instance details

Defined in Options.Applicative.Types

Methods

showsPrec :: Int -> OptName -> ShowS

show :: OptName -> String

showList :: [OptName] -> ShowS

data OptReader a Source #

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

Constructors

OptReader [OptName] (CReader a) (String -> ParseError)

option reader

FlagReader [OptName] !a

flag reader

ArgReader (CReader a)

argument reader

CmdReader (Maybe String) [String] (String -> Maybe (ParserInfo a))

command reader

Instances
Functor OptReader Source # 
Instance details

Defined in Options.Applicative.Types

Methods

fmap :: (a -> b) -> OptReader a -> OptReader b

(<$) :: a -> OptReader b -> OptReader a

data OptProperties Source #

Specification for an individual parser option.

Constructors

OptProperties 

Fields

Instances
Show OptProperties Source # 
Instance details

Defined in Options.Applicative.Types

Methods

showsPrec :: Int -> OptProperties -> ShowS

show :: OptProperties -> String

showList :: [OptProperties] -> ShowS

data OptVisibility Source #

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 Source # 
Instance details

Defined in Options.Applicative.Types

Ord OptVisibility Source # 
Instance details

Defined in Options.Applicative.Types

Show OptVisibility Source # 
Instance details

Defined in Options.Applicative.Types

Methods

showsPrec :: Int -> OptVisibility -> ShowS

show :: OptVisibility -> String

showList :: [OptVisibility] -> ShowS

newtype ReadM a Source #

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

Constructors

ReadM 

Fields

Instances
Monad ReadM Source # 
Instance details

Defined in Options.Applicative.Types

Methods

(>>=) :: ReadM a -> (a -> ReadM b) -> ReadM b

(>>) :: ReadM a -> ReadM b -> ReadM b

return :: a -> ReadM a

fail :: String -> ReadM a

Functor ReadM Source # 
Instance details

Defined in Options.Applicative.Types

Methods

fmap :: (a -> b) -> ReadM a -> ReadM b

(<$) :: a -> ReadM b -> ReadM a

MonadFail ReadM Source # 
Instance details

Defined in Options.Applicative.Types

Methods

fail :: String -> ReadM a

Applicative ReadM Source # 
Instance details

Defined in Options.Applicative.Types

Methods

pure :: a -> ReadM a

(<*>) :: ReadM (a -> b) -> ReadM a -> ReadM b

liftA2 :: (a -> b -> c) -> ReadM a -> ReadM b -> ReadM c

(*>) :: ReadM a -> ReadM b -> ReadM b

(<*) :: ReadM a -> ReadM b -> ReadM a

Alternative ReadM Source # 
Instance details

Defined in Options.Applicative.Types

Methods

empty :: ReadM a

(<|>) :: ReadM a -> ReadM a -> ReadM a

some :: ReadM a -> ReadM [a]

many :: ReadM a -> ReadM [a]

MonadPlus ReadM Source # 
Instance details

Defined in Options.Applicative.Types

Methods

mzero :: ReadM a

mplus :: ReadM a -> ReadM a -> ReadM a

readerAsk :: ReadM String Source #

Return the value being read.

readerAbort :: ParseError -> ReadM a Source #

Abort option reader by exiting with a ParseError.

readerError :: String -> ReadM a Source #

Abort option reader by exiting with an error message.

data CReader a Source #

Constructors

CReader 
Instances
Functor CReader Source # 
Instance details

Defined in Options.Applicative.Types

Methods

fmap :: (a -> b) -> CReader a -> CReader b

(<$) :: a -> CReader b -> CReader a

data Parser a Source #

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

Constructors

NilP (Maybe a) 
OptP (Option a) 
MultP (Parser (x -> a)) (Parser x) 
AltP (Parser a) (Parser a) 
BindP (Parser x) (x -> Parser a) 
Instances
Functor Parser Source # 
Instance details

Defined in Options.Applicative.Types

Methods

fmap :: (a -> b) -> Parser a -> Parser b

(<$) :: a -> Parser b -> Parser a

Applicative Parser Source # 
Instance details

Defined in Options.Applicative.Types

Methods

pure :: a -> Parser a

(<*>) :: Parser (a -> b) -> Parser a -> Parser b

liftA2 :: (a -> b -> c) -> Parser a -> Parser b -> Parser c

(*>) :: Parser a -> Parser b -> Parser b

(<*) :: Parser a -> Parser b -> Parser a

Alternative Parser Source # 
Instance details

Defined in Options.Applicative.Types

Methods

empty :: Parser a

(<|>) :: Parser a -> Parser a -> Parser a

some :: Parser a -> Parser [a]

many :: Parser a -> Parser [a]

newtype ParserM r Source #

Constructors

ParserM 

Fields

Instances
Monad ParserM Source # 
Instance details

Defined in Options.Applicative.Types

Methods

(>>=) :: ParserM a -> (a -> ParserM b) -> ParserM b

(>>) :: ParserM a -> ParserM b -> ParserM b

return :: a -> ParserM a

fail :: String -> ParserM a

Functor ParserM Source # 
Instance details

Defined in Options.Applicative.Types

Methods

fmap :: (a -> b) -> ParserM a -> ParserM b

(<$) :: a -> ParserM b -> ParserM a

Applicative ParserM Source # 
Instance details

Defined in Options.Applicative.Types

Methods

pure :: a -> ParserM a

(<*>) :: ParserM (a -> b) -> ParserM a -> ParserM b

liftA2 :: (a -> b -> c) -> ParserM a -> ParserM b -> ParserM c

(*>) :: ParserM a -> ParserM b -> ParserM b

(<*) :: ParserM a -> ParserM b -> ParserM a

newtype Completer Source #

A shell complete function.

Constructors

Completer 

Fields

Instances
Semigroup Completer Source # 
Instance details

Defined in Options.Applicative.Types

Methods

(<>) :: Completer -> Completer -> Completer

sconcat :: NonEmpty Completer -> Completer

stimes :: Integral b => b -> Completer -> Completer

Monoid Completer Source # 
Instance details

Defined in Options.Applicative.Types

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

Smart constructor for a Completer

newtype CompletionResult Source #

Constructors

CompletionResult 

Fields

Instances
Show CompletionResult Source # 
Instance details

Defined in Options.Applicative.Types

Methods

showsPrec :: Int -> CompletionResult -> ShowS

show :: CompletionResult -> String

showList :: [CompletionResult] -> ShowS

newtype ParserFailure h Source #

Constructors

ParserFailure 

Fields

Instances
Functor ParserFailure Source # 
Instance details

Defined in Options.Applicative.Types

Methods

fmap :: (a -> b) -> ParserFailure a -> ParserFailure b

(<$) :: a -> ParserFailure b -> ParserFailure a

Show h => Show (ParserFailure h) Source # 
Instance details

Defined in Options.Applicative.Types

Methods

showsPrec :: Int -> ParserFailure h -> ShowS

show :: ParserFailure h -> String

showList :: [ParserFailure h] -> ShowS

data ParserResult a Source #

Result of execParserPure.

Instances
Monad ParserResult Source # 
Instance details

Defined in Options.Applicative.Types

Methods

(>>=) :: ParserResult a -> (a -> ParserResult b) -> ParserResult b

(>>) :: ParserResult a -> ParserResult b -> ParserResult b

return :: a -> ParserResult a

fail :: String -> ParserResult a

Functor ParserResult Source # 
Instance details

Defined in Options.Applicative.Types

Methods

fmap :: (a -> b) -> ParserResult a -> ParserResult b

(<$) :: a -> ParserResult b -> ParserResult a

Applicative ParserResult Source # 
Instance details

Defined in Options.Applicative.Types

Show a => Show (ParserResult a) Source # 
Instance details

Defined in Options.Applicative.Types

Methods

showsPrec :: Int -> ParserResult a -> ShowS

show :: ParserResult a -> String

showList :: [ParserResult a] -> ShowS

type Args = [String] Source #

data ArgPolicy Source #

Policy for how to handle options within the parse

Constructors

Intersperse

The default policy, options and arguments can be interspersed. A `--` option can be passed to ensure all following commands are treated as arguments.

NoIntersperse

Options must all come before arguments, once a single positional argument or subcommand is parsed, all remaining arguments are treated as positionals. A `--` option can be passed if the first positional one needs starts with -.

AllPositionals

No options are parsed at all, all arguments are treated as positionals. Is the policy used after `--` is encountered.

ForwardOptions

Options and arguments can be interspersed, but if a given option is not found, it is treated as a positional argument. This is sometimes useful if one is passing through most options to another tool, but are supplying just a few of their own options.

Instances
Eq ArgPolicy Source # 
Instance details

Defined in Options.Applicative.Types

Methods

(==) :: ArgPolicy -> ArgPolicy -> Bool

(/=) :: ArgPolicy -> ArgPolicy -> Bool

Ord ArgPolicy Source # 
Instance details

Defined in Options.Applicative.Types

Methods

compare :: ArgPolicy -> ArgPolicy -> Ordering

(<) :: ArgPolicy -> ArgPolicy -> Bool

(<=) :: ArgPolicy -> ArgPolicy -> Bool

(>) :: ArgPolicy -> ArgPolicy -> Bool

(>=) :: ArgPolicy -> ArgPolicy -> Bool

max :: ArgPolicy -> ArgPolicy -> ArgPolicy

min :: ArgPolicy -> ArgPolicy -> ArgPolicy

Show ArgPolicy Source # 
Instance details

Defined in Options.Applicative.Types

Methods

showsPrec :: Int -> ArgPolicy -> ShowS

show :: ArgPolicy -> String

showList :: [ArgPolicy] -> ShowS

data OptHelpInfo Source #

Constructors

OptHelpInfo 

Fields

  • hinfoMulti :: Bool

    Whether this is part of a many or some (approximately)

  • hinfoDefault :: Bool

    Whether this option has a default value

  • hinfoUnreachableArgs :: Bool

    If the result is a positional, if it can't be accessed in the current parser position ( first arg )

Instances
Eq OptHelpInfo Source # 
Instance details

Defined in Options.Applicative.Types

Methods

(==) :: OptHelpInfo -> OptHelpInfo -> Bool

(/=) :: OptHelpInfo -> OptHelpInfo -> Bool

Show OptHelpInfo Source # 
Instance details

Defined in Options.Applicative.Types

Methods

showsPrec :: Int -> OptHelpInfo -> ShowS

show :: OptHelpInfo -> String

showList :: [OptHelpInfo] -> ShowS

data OptTree a Source #

Constructors

Leaf a 
MultNode [OptTree a] 
AltNode [OptTree a] 
Instances
Show a => Show (OptTree a) Source # 
Instance details

Defined in Options.Applicative.Types

Methods

showsPrec :: Int -> OptTree a -> ShowS

show :: OptTree a -> String

showList :: [OptTree a] -> ShowS

data ParserHelp Source #

Instances
Show ParserHelp Source # 
Instance details

Defined in Options.Applicative.Help.Types

Methods

showsPrec :: Int -> ParserHelp -> ShowS

show :: ParserHelp -> String

showList :: [ParserHelp] -> ShowS

Semigroup ParserHelp Source # 
Instance details

Defined in Options.Applicative.Help.Types

Methods

(<>) :: ParserHelp -> ParserHelp -> ParserHelp

sconcat :: NonEmpty ParserHelp -> ParserHelp

stimes :: Integral b => b -> ParserHelp -> ParserHelp

Monoid ParserHelp Source # 
Instance details

Defined in Options.Applicative.Help.Types

data SomeParser Source #

Constructors

SomeParser (Parser a) 

data Context Source #

Subparser context, containing the name of the subparser, and its parser info. Used by parserFailure to display relevant usage information when parsing inside a subparser fails.

Constructors

Context String (ParserInfo a) 

data IsCmdStart Source #

Constructors

CmdStart 
CmdCont 
Instances
Show IsCmdStart Source # 
Instance details

Defined in Options.Applicative.Types

Methods

showsPrec :: Int -> IsCmdStart -> ShowS

show :: IsCmdStart -> String

showList :: [IsCmdStart] -> ShowS

optMetaVar :: Option a -> String Source #

optShowDefault :: Option a -> Maybe String Source #

optDescMod :: Option a -> Maybe (Doc -> Doc) Source #