Options.Applicative.Types
- Package
- purescript-optparse
- Repository
- f-o-a-m/purescript-optparse
#ParserInfo Source
newtype ParserInfo a
A 'ParserInfo' describes a command line program, used to generate a help screen. Two help modes are supported: brief and full. In brief mode, only an option and argument summary is displayed, while in full mode each available option and command, including hidden ones, is described.
A basic 'ParserInfo' with default values for fields can be created using the 'info' function.
Constructors
ParserInfo { infoFailureCode :: ExitCode, infoFooter :: Chunk Doc, infoFullDesc :: Boolean, infoHeader :: Chunk Doc, infoParser :: Parser a, infoPolicy :: ArgPolicy, infoProgDesc :: Chunk Doc }
Instances
#ParserPrefs Source
newtype ParserPrefs
Global preferences for a top-level 'Parser'. A 'ParserPrefs' contains general preferences for all command-line options, and can be built with the 'prefs' function.
Constructors
ParserPrefs { prefBacktrack :: Backtracking, prefColumns :: Int, prefDisambiguate :: Boolean, prefMultiSuffix :: String, prefShowHelpOnEmpty :: Boolean, prefShowHelpOnError :: Boolean }
Instances
#OptReader Source
#OptProperties Source
newtype OptProperties
Specification for an individual parser option.
Constructors
OptProperties { propDescMod :: Maybe (Doc -> Doc), propHelp :: Chunk Doc, propMetaVar :: String, propShowDefault :: Maybe String, propVisibility :: OptVisibility }
Instances
#OptVisibility Source
#Backtracking Source
#ReadM Source
newtype ReadM a
A reader is used by the 'option' and 'argument' builders to parse the data passed by the user on the command line into a data type.
The most common are 'str' which is used for 'String', there are
readers for Int
, Number
, Boolean
.
More complex types can use the 'eitherReader' or 'maybeReader' functions to pattern match or use a more expressive parser like a member of the 'Parsec' family. A newtype over 'ReaderT String Except', used by option readers.
Constructors
ReadM (ReaderT String (Except ParseError) a)
Instances
#readerAbort Source
readerAbort :: forall a. ParseError -> ReadM a
Abort option reader by exiting with a 'ParseError'.
#readerError Source
readerError :: forall a. String -> ReadM a
Abort option reader by exiting with an error message.
#Parser Source
data Parser a
A 'Parser' is the core type in optparse-applicative. A value of type Parser a@ represents a specification for a set of options, which will yield a value of type a when the command line arguments are successfully parsed.
There are several types of primitive 'Parser'.
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.
** Parser builders
Each parser builder takes an option modifier. A modifier can be created by composing the basic modifiers provided by here using the 'Monoid' operations mempty' and 'append', or their aliases 'idm' and '<>'.
For example:
out = strOption ( long "output" <> short 'o' <> metavar "FILENAME" )
creates a parser for an option called "output".
Constructors
Instances
#Completer Source
newtype Completer
optparse-applicative supplies a rich completion system for bash, zsh, and fish shells.
'Completer' functions are used for option and argument to complete their values.
Use the 'completer' builder to use these. The 'action' and 'completeWith' builders are also provided for convenience, to use 'bashCompleter' and 'listCompleter' as a 'Mod'.
Constructors
Instances
#CompletionResult Source
newtype CompletionResult
Constructors
CompletionResult { execCompletion :: String -> Effect String }
Instances
#ParserFailure Source
#ParserResult Source
#overFailure Source
overFailure :: forall a. (ParserHelp -> ParserHelp) -> ParserResult a -> ParserResult a
#ArgPolicy Source
#OptHelpInfo Source
newtype OptHelpInfo
Constructors
OptHelpInfo { hinfoDefault :: Boolean, hinfoMulti :: Boolean, hinfoUnreachableArgs :: Boolean }
Instances
#Context Source
data Context
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
#optVisibility Source
optVisibility :: forall a. Option a -> OptVisibility
#optMetaVar Source
optMetaVar :: forall a. Option a -> String
#many Source
many :: forall a. Parser a -> Parser (List a)
Parses 0 or more values using the given parser. Note: this should
never be used with the value
modifier.
For example, by using this option
many (strOption (long "arg-name"))
one could write
command
# produces Nil
command --arg-name first
# produces ("first" : Nil)
command --arg-name first --arg-name second
# produces ("first" : "second" : Nil)
To parse 1 or more values, see some
instead.
#some Source
some :: forall a. Parser a -> Parser (NonEmptyList a)
Parses 1 or more values using the given parser. Note: this should
never be used with the value
modifier.
For example, by using this option
some (strOption (long "arg-name"))
one could write
command
# produces failure message
command --arg-name first
# produces (NonEmptyList "first" Nil)
command --arg-name first --arg-name second
# produces (NonEmptyList "first" ("second" : Nil))
To parse 0 or more values, see many
instead.
Re-exports from Options.Applicative.Help.Types
- Modules
- Options.
Applicative - Options.
Applicative. BashCompletion - Options.
Applicative. Builder - Options.
Applicative. Builder. Completer - Options.
Applicative. Builder. Internal - Options.
Applicative. Common - Options.
Applicative. Extra - Options.
Applicative. Help - Options.
Applicative. Help. Chunk - Options.
Applicative. Help. Core - Options.
Applicative. Help. Levenshtein - Options.
Applicative. Help. Pretty - Options.
Applicative. Help. Types - Options.
Applicative. Internal - Options.
Applicative. Internal. Utils - Options.
Applicative. Types - Text.
PrettyPrint. Leijen