descriptive-0.9.4: Self-describing consumers/parsers; forms, cmd-line args, JSON, etc.

Safe HaskellSafe-Inferred
LanguageHaskell98

Descriptive.Options

Contents

Description

Command-line options parser.

Synopsis

Existence flags

flag Source

Arguments

:: Monad m 
=> Text

Name.

-> Text

Description.

-> v

Value returned when present.

-> Consumer [Text] (Option a) m v 

Find a value flag which must succeed. Removes it from the argument list if it succeeds.

switch Source

Arguments

:: Monad m 
=> Text

Name.

-> Text

Description.

-> Consumer [Text] (Option a) m Bool 

Find a boolean flag. Always succeeds. Omission counts as False. Removes it from the argument list if it returns True.

Text input arguments

prefix Source

Arguments

:: Monad m 
=> Text

Prefix string.

-> Text

Description.

-> Consumer [Text] (Option a) m Text 

Find an argument prefixed by -X. Removes it from the argument list when it succeeds.

arg Source

Arguments

:: Monad m 
=> Text

Name.

-> Text

Description.

-> Consumer [Text] (Option a) m Text 

Find a named argument e.g. --name value. Removes it from the argument list when it succeeds.

Token consumers

anyString :: Monad m => Text -> Consumer [Text] (Option a) m Text Source

Consume one argument from the argument list and pops it from the start of the list.

constant Source

Arguments

:: Monad m 
=> Text

String.

-> Text

Description.

-> v 
-> Consumer [Text] (Option a) m v 

Consume one argument from the argument list which must match the given string, and also pops it off the argument list.

Special control

stop Source

Arguments

:: Monad m 
=> Consumer [Text] (Option a) m a

A parser which, when it succeeds, causes the whole parser to stop.

-> Consumer [Text] (Option a) m () 

If the consumer succeeds, stops the whole parser and returns Stopped immediately.

Description

data Option a Source

Description of a commandline option.

Instances

Eq a => Eq (Option a) 
Show a => Show (Option a) 

textDescription :: Description (Option a) -> Text Source

Make a text description of the command line options.

textOpt :: Option a -> Text Source

Make a text description of an option.