Safe Haskell | None |
---|---|
Language | Haskell2010 |
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).
- data Flag p = Flag {}
- flagHelp :: Doc -> Flag p
- flagHelpStr :: String -> Flag p
- flagDefault :: p -> Flag p
- flagHidden :: Flag p
- addSimpleBoolFlag :: Applicative f => String -> [String] -> Flag Void -> CmdParser f out Bool
- addSimpleCountFlag :: Applicative f => String -> [String] -> Flag Void -> CmdParser f out Int
- addSimpleFlagA :: String -> [String] -> Flag Void -> f () -> CmdParser f out ()
- addFlagReadParam :: forall f p out. (Applicative f, Typeable p, Read p, Show p) => String -> [String] -> String -> Flag p -> CmdParser f out p
- addFlagReadParams :: forall f p out. (Applicative f, Typeable p, Read p, Show p) => String -> [String] -> String -> Flag p -> CmdParser f out [p]
- addFlagStringParam :: forall f out. Applicative f => String -> [String] -> String -> Flag String -> CmdParser f out String
- addFlagStringParams :: forall f out. Applicative f => String -> [String] -> String -> Flag Void -> CmdParser f out [String]
Documentation
flag-description monoid. You probably won't need to use the constructor; mzero or any (<>) of flag(Help|Default) works well.
Flag | |
|
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.
:: 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.
:: 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).
:: 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
:: (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.
:: (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].
:: 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.
:: 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"].