Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Helps you build command-line parsers for programs that have more
than one so-called mode; examples of such programs include git
,
darcs
, and ghc-pkg
.
- data ArgSpec a
- data OptSpec a
- optSpec :: [Char] -> [String] -> ArgSpec a -> OptSpec a
- data Mode r
- mode :: String -> [OptSpec a] -> (String -> a) -> ([a] -> r) -> Mode r
- data ModeResult g r = ModeResult [g] (Either [String] r)
- parseModeLine :: [OptSpec g] -> [Mode r] -> [String] -> Either (String, [String]) (ModeResult g r)
Documentation
Specifies how many option arguments an option takes.
Specifies an option. Typically you will use optSpec
to
create an OptSpec
rather than using the constructor directly.
Each OptSpec
may contain mulitple short option names and
long option names; but each OptSpec
contains only one ArgSpec
.
Therefore, all short option names and long option names
specified in a single OptSpec
are synonymous.
:: [Char] | There is one character for each desired short option name.
Each of these characters may not be a hyphen; otherwise,
|
-> [String] | There is one string for each desired long option name. Each string:
|
-> ArgSpec a | How many option arguments this option takes. This also specifies what is returned when the option is parsed on the command line. |
-> OptSpec a |
Creates an OptSpec
.
A Mode
represents a single command line mode, such as check
for ghc-pkg check
. It contains the name of the mode, as well as
a parser that handles all options and positional arguments for
the mode. Ordinarily you will create a Mode
using the mode
function rather than by using the constructor directly.
:: String | Mode name. For instance, for the |
-> [OptSpec a] | Mode options |
-> (String -> a) | Parses positional arguments |
-> ([a] -> r) | Processes the result of all mode options |
-> Mode r |
Creates a new Mode
.
data ModeResult g r Source
The result of parsing a mode command line.
ModeResult [g] (Either [String] r) |
If |
(Eq g, Eq r) => Eq (ModeResult g r) | |
(Ord g, Ord r) => Ord (ModeResult g r) | |
(Show g, Show r) => Show (ModeResult g r) |
:: [OptSpec g] | Global options. This might, for example, include a |
-> [Mode r] | All modes |
-> [String] | All command line words |
-> Either (String, [String]) (ModeResult g r) | Returns
|
Parses a command line that may contain modes.