Safe Haskell | None |
---|---|
Language | Haskell2010 |
Parameters are arguments of your current command that are not prefixed by some flag. Typical commandline interface is something like "PROGRAM [FLAGS] INPUT". Here, FLAGS are Flags in butcher, and INPUT is a Param, in this case a String representing a path, for example.
- data Param p = Param {
- _param_default :: Maybe p
- _param_help :: Maybe Doc
- _param_suggestions :: Maybe [CompletionItem]
- paramHelp :: Doc -> Param p
- paramHelpStr :: String -> Param p
- paramDefault :: p -> Param p
- paramSuggestions :: [String] -> Param p
- paramFile :: Param p
- paramDirectory :: Param p
- addParamRead :: forall f out a. (Applicative f, Typeable a, Show a, Read a) => String -> Param a -> CmdParser f out a
- addParamReadOpt :: forall f out a. (Applicative f, Typeable a, Read a) => String -> Param a -> CmdParser f out (Maybe a)
- addParamString :: forall f out. Applicative f => String -> Param String -> CmdParser f out String
- addParamStringOpt :: forall f out. Applicative f => String -> Param Void -> CmdParser f out (Maybe String)
- addParamStrings :: forall f out. Applicative f => String -> Param Void -> CmdParser f out [String]
- addParamNoFlagString :: forall f out. Applicative f => String -> Param String -> CmdParser f out String
- addParamNoFlagStringOpt :: forall f out. Applicative f => String -> Param Void -> CmdParser f out (Maybe String)
- addParamNoFlagStrings :: forall f out. Applicative f => String -> Param Void -> CmdParser f out [String]
- addParamRestOfInput :: forall f out. Applicative f => String -> Param Void -> CmdParser f out String
- addParamRestOfInputRaw :: forall f out. Applicative f => String -> Param Void -> CmdParser f out Input
- addReadParam :: forall f out a. (Applicative f, Typeable a, Show a, Read a) => String -> Param a -> CmdParser f out a
- addReadParamOpt :: forall f out a. (Applicative f, Typeable a, Read a) => String -> Param a -> CmdParser f out (Maybe a)
- addStringParam :: forall f out. Applicative f => String -> Param String -> CmdParser f out String
- addStringParamOpt :: forall f out. Applicative f => String -> Param Void -> CmdParser f out (Maybe String)
- addStringParams :: forall f out. Applicative f => String -> Param Void -> CmdParser f out [String]
- addRestOfInputStringParam :: forall f out. Applicative f => String -> Param Void -> CmdParser f out String
Documentation
param-description monoid. You probably won't need to use the constructor; mzero or any (<>) of param(Help|Default|Suggestion) works well.
Param | |
|
paramDefault :: p -> Param p Source #
Create a Param
with just a default value.
paramSuggestions :: [String] -> Param p Source #
Create a Param
with just a list of suggestion values.
paramDirectory :: Param p Source #
Create a Param
that is a directory path.
:: (Applicative f, Typeable a, Read a) | |
=> String | paramater name, for use in usage/help texts |
-> Param a | properties |
-> CmdParser f out (Maybe a) |
Like addReadParam, but optional. I.e. if reading fails, returns Nothing.
addParamString :: forall f out. Applicative f => String -> Param String -> CmdParser f out String Source #
Add a parameter that matches any string of non-space characters if
input==String, or one full argument if input==[String]. See the Input
doc
for this distinction.
addParamStringOpt :: forall f out. Applicative f => String -> Param Void -> CmdParser f out (Maybe String) Source #
Like addParamString
, but optional, I.e. succeeding with Nothing if
there is no remaining input.
addParamStrings :: forall f out. Applicative f => String -> Param Void -> CmdParser f out [String] Source #
Add a parameter that matches any string of non-space characters if
input==String, or one full argument if input==[String]. See the Input
doc
for this distinction.
addParamNoFlagString :: forall f out. Applicative f => String -> Param String -> CmdParser f out String Source #
Like addParamString
but does not match strings starting with a dash.
This prevents misinterpretation of flags as params.
addParamNoFlagStringOpt :: forall f out. Applicative f => String -> Param Void -> CmdParser f out (Maybe String) Source #
Like addParamStringOpt
but does not match strings starting with a dash.
This prevents misinterpretation of flags as params.
addParamNoFlagStrings :: forall f out. Applicative f => String -> Param Void -> CmdParser f out [String] Source #
Like addParamStrings
but does not match strings starting with a dash.
This prevents misinterpretation of flags as params.
addParamRestOfInput :: forall f out. Applicative f => String -> Param Void -> CmdParser f out String Source #
Add a parameter that consumes _all_ remaining input. Typical usecase is after a "--" as common in certain (unix?) commandline tools.
addParamRestOfInputRaw :: forall f out. Applicative f => String -> Param Void -> CmdParser f out Input Source #
Add a parameter that consumes _all_ remaining input, returning a raw
Input
value.
Deprecated for more consistent naming
:: (Applicative f, Typeable a, Show a, Read a) | |
=> String | paramater name, for use in usage/help texts |
-> Param a | properties |
-> CmdParser f out a |
Deprecated: use addParamRead
:: (Applicative f, Typeable a, Read a) | |
=> String | paramater name, for use in usage/help texts |
-> Param a | properties |
-> CmdParser f out (Maybe a) |
Deprecated: use addParamReadOpt
addStringParam :: forall f out. Applicative f => String -> Param String -> CmdParser f out String Source #
Deprecated: use addParamString
addStringParamOpt :: forall f out. Applicative f => String -> Param Void -> CmdParser f out (Maybe String) Source #
Deprecated: use addParamStringOpt
addStringParams :: forall f out. Applicative f => String -> Param Void -> CmdParser f out [String] Source #
Deprecated: use addParamStrings
addRestOfInputStringParam :: forall f out. Applicative f => String -> Param Void -> CmdParser f out String Source #
Deprecated: use addParamRestOfInput