Options.Applicative.Builder
- Package
- purescript-optparse
- Repository
- f-o-a-m/purescript-optparse
#subparser Source
subparser :: forall a. Mod CommandFields a -> Parser aBuilder for a command parser. The 'command' modifier can be used to
#strArgument Source
strArgument :: Mod ArgumentFields String -> Parser StringBuilder for a 'String' argument.
#argument Source
argument :: forall a. ReadM a -> Mod ArgumentFields a -> Parser aBuilder for an argument parser.
#flag' Source
flag' :: forall a. a -> Mod FlagFields a -> Parser aBuilder for a flag parser without a default value.
#abortOption Source
abortOption :: forall a. ParseError -> Mod OptionFields (a -> a) -> Parser (a -> a)An option that always fails.
#infoOption Source
infoOption :: forall a. String -> Mod OptionFields (a -> a) -> Parser (a -> a)An option that always fails and displays a message.
#option Source
option :: forall a. ReadM a -> Mod OptionFields a -> Parser aBuilder for an option using the given reader.
#showDefaultWith Source
showDefaultWith :: forall a f. (a -> String) -> Mod f aSpecify a function to show the default value for an option.
#showDefault Source
showDefault :: forall a f. Show a => Mod f aShow the default value for this option using its 'Show' instance.
#metavar Source
metavar :: forall a f. HasMetavar f => String -> Mod f aSpecify a metavariable for the argument.
#noArgError Source
noArgError :: forall a. ParseError -> Mod OptionFields aSpecify the error to display when no argument is provided to this option.
#command Source
command :: forall a. String -> ParserInfo a -> Mod CommandFields aAdd a command to a subparser option.
#commandGroup Source
commandGroup :: forall a. String -> Mod CommandFields aAdd a description to a group of commands.
#completeWith Source
completeWith :: forall a f. HasCompleter f => Array String -> Mod f aAdd a list of possible completion values.
#action Source
action :: forall a f. HasCompleter f => String -> Mod f aAdd a bash completion action. Common actions include @file@ and
#completer Source
completer :: forall a f. HasCompleter f => Completer -> Mod f aAdd a completer to an argument.
#maybeReader Source
maybeReader :: forall a. (String -> Maybe a) -> ReadM aConvert a function producing a 'Maybe' into a reader.
#eitherReader Source
eitherReader :: forall a. (String -> Either String a) -> ReadM aConvert a function producing an 'Either' into a reader.
#progDescDoc Source
progDescDoc :: forall a. Maybe Doc -> InfoMod aSpecify a short program description as a 'Text.PrettyPrint.ANSI.Leijen.Doc'
#failureCode Source
failureCode :: forall a. ExitCode -> InfoMod aSpecify an exit code if a parse error occurs.
#noIntersperse Source
noIntersperse :: forall a. InfoMod aDisable parsing of regular options after arguments. After a positional
#forwardOptions Source
forwardOptions :: forall a. InfoMod aIntersperse matched options and arguments normally, but allow unmatched
#info Source
info :: forall a. Parser a -> InfoMod a -> ParserInfo aCreate a 'ParserInfo' given a 'Parser' and a modifier.
#multiSuffix Source
multiSuffix :: String -> PrefsModInclude a suffix to attach to the metavar when multiple values
#disambiguate Source
disambiguate :: PrefsModTurn on disambiguation.
#showHelpOnError Source
showHelpOnError :: PrefsModShow full help text on any error.
#showHelpOnEmpty Source
showHelpOnEmpty :: PrefsModShow the help text if the user enters only the program name or
#noBacktrack Source
noBacktrack :: PrefsModTurn off backtracking after subcommand is parsed.
#subparserInline Source
subparserInline :: PrefsModAllow full mixing of subcommand and parent arguments by inlining
#prefs Source
prefs :: PrefsMod -> ParserPrefsCreate a ParserPrefs given a modifier
#defaultPrefs Source
defaultPrefs :: ParserPrefsDefault preferences.
Re-exports from Options.Applicative.Builder.Internal
#OptionFields Source
newtype OptionFields aInstances
#Mod Source
data Mod f aAn option modifier.
Option modifiers are values that represent a modification of the properties of an option.
The type parameter @a@ is the pure type of the option, while @f@ is a record containing its properties (e.g. 'OptionFields' for regular options, 'FlagFields' for flags, etc...).
An option modifier consists of 3 elements:
A field modifier, of the form @f a -> f a@. These are essentially (compositions of) setters for some of the properties supported by @f@.
An optional default value and function to display it.
A property modifier, of the form @OptProperties -> OptProperties@. This is just like the field modifier, but for properties applicable to any option.
Modifiers are instances of 'Monoid', and can be composed as such.
One rarely needs to deal with modifiers directly, as most of the times it is sufficient to pass them to builders (such as 'strOption' or 'flag') to create options (see 'Options.Applicative.Builder').
Contraints are often used to ensure that the modifiers can be sensibly applied. For example, positional arguments can't be specified by long or short names, so the 'HasName' constraint is used to ensure we have a flag or option.
Instances
#ArgumentFields Source
newtype ArgumentFields aInstances
#HasMetavar Source
class HasMetavar f Instances
Re-exports from Options.Applicative.Types
#ReadM Source
newtype ReadM aA 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.
Instances
#readerError Source
readerError :: forall a. String -> ReadM aAbort option reader by exiting with an error message.
#readerAbort Source
readerAbort :: forall a. ParseError -> ReadM aAbort option reader by exiting with a 'ParseError'.
- 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
@since 0.13.0.0