butcher-1.3.3.2: Chops a command or program invocation into digestable pieces.

Safe HaskellNone
LanguageHaskell2010

UI.Butcher.Monadic.Flag

Description

Flags are arguments to your current command that are prefixed with "-" or "--", for example "-v" or "--verbose". These flags can have zero or one argument. (Butcher internally has more general concept of CmdPart that could handle any number of arguments, so take this as what this module aims to provide, not what you could theoretically implement on top of butcher).

Synopsis

Documentation

data Flag p Source #

flag-description monoid. You probably won't need to use the constructor; mzero or any (<>) of flag(Help|Default) works well.

Instances
Semigroup (Flag p) Source # 
Instance details

Defined in UI.Butcher.Monadic.Flag

Methods

(<>) :: Flag p -> Flag p -> Flag p #

sconcat :: NonEmpty (Flag p) -> Flag p #

stimes :: Integral b => b -> Flag p -> Flag p #

Monoid (Flag p) Source # 
Instance details

Defined in UI.Butcher.Monadic.Flag

Methods

mempty :: Flag p #

mappend :: Flag p -> Flag p -> Flag p #

mconcat :: [Flag p] -> Flag p #

flagHelp :: Doc -> Flag p Source #

Create a Flag with just a help text.

flagHelpStr :: String -> Flag p Source #

Create a Flag with just a help text.

flagDefault :: p -> Flag p Source #

Create a Flag with just a default value.

flagHidden :: Flag p Source #

Create a Flag marked as hidden. Similar to hidden commands, hidden flags will not included in pretty-printing (help, usage etc.)

This feature is not well tested yet.

addSimpleBoolFlag Source #

Arguments

:: Applicative f 
=> String

short flag chars, i.e. "v" for -v

-> [String]

list of long names, e.g. ["verbose"]

-> Flag Void

properties

-> CmdParser f out Bool 

A no-parameter flag where non-occurence means False, occurence means True.

addSimpleCountFlag Source #

Arguments

:: Applicative f 
=> String

short flag chars, i.e. "v" for -v

-> [String]

list of long names, i.e. ["verbose"]

-> Flag Void

properties

-> CmdParser f out Int 

A no-parameter flag that can occur multiple times. Returns the number of occurences (0 or more).

addSimpleFlagA Source #

Arguments

:: String

short flag chars, i.e. "v" for -v

-> [String]

list of long names, e.g. ["verbose"]

-> Flag Void

properties

-> f ()

action to execute whenever this matches

-> CmdParser f out () 

Applicative-enabled version of addSimpleFlag

addFlagReadParam Source #

Arguments

:: (Applicative f, Typeable p, Read p, Show p) 
=> String

short flag chars, i.e. "v" for -v

-> [String]

list of long names, i.e. ["verbose"]

-> String

param name

-> Flag p

properties

-> CmdParser f out p 

One-argument flag, where the argument is parsed via its Read instance.

addFlagReadParams Source #

Arguments

:: (Applicative f, Typeable p, Read p, Show p) 
=> String

short flag chars, i.e. "v" for -v

-> [String]

list of long names, i.e. ["verbose"]

-> String

param name

-> Flag p

properties

-> CmdParser f out [p] 

One-argument flag, where the argument is parsed via its Read instance. This version can accumulate multiple values by using the same flag with different arguments multiple times.

E.g. "--foo 3 --foo 5" yields [3,5].

addFlagStringParam Source #

Arguments

:: Applicative f 
=> String

short flag chars, i.e. "v" for -v

-> [String]

list of long names, i.e. ["verbose"]

-> String

param name

-> Flag String

properties

-> CmdParser f out String 

One-argument flag where the argument can be an arbitrary string.

addFlagStringParams Source #

Arguments

:: Applicative f 
=> String

short flag chars, i.e. "v" for -v

-> [String]

list of long names, i.e. ["verbose"]

-> String

param name

-> Flag Void

properties

-> CmdParser f out [String] 

One-argument flag where the argument can be an arbitrary string. This version can accumulate multiple values by using the same flag with different arguments multiple times.

E.g. "--foo abc --foo def" yields ["abc", "def"].