Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Multiarg.Mode
Description
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
.
Synopsis
- 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.
Constructors
ZeroArg a | This option takes no option arguments |
OneArg (String -> a) | This option takes one option argument |
TwoArg (String -> String -> a) | This option takes two option arguments |
ThreeArg (String -> String -> String -> a) | This option takes three option arguments |
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.
Arguments
:: [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.
Arguments
:: 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.
Constructors
ModeResult [g] (Either [String] r) |
If |
Instances
(Show g, Show r) => Show (ModeResult g r) Source # | |
Defined in Multiarg.Mode.Internal Methods showsPrec :: Int -> ModeResult g r -> ShowS # show :: ModeResult g r -> String # showList :: [ModeResult g r] -> ShowS # | |
(Eq g, Eq r) => Eq (ModeResult g r) Source # | |
Defined in Multiarg.Mode.Internal Methods (==) :: ModeResult g r -> ModeResult g r -> Bool # (/=) :: ModeResult g r -> ModeResult g r -> Bool # | |
(Ord g, Ord r) => Ord (ModeResult g r) Source # | |
Defined in Multiarg.Mode.Internal Methods compare :: ModeResult g r -> ModeResult g r -> Ordering # (<) :: ModeResult g r -> ModeResult g r -> Bool # (<=) :: ModeResult g r -> ModeResult g r -> Bool # (>) :: ModeResult g r -> ModeResult g r -> Bool # (>=) :: ModeResult g r -> ModeResult g r -> Bool # max :: ModeResult g r -> ModeResult g r -> ModeResult g r # min :: ModeResult g r -> ModeResult g r -> ModeResult g r # |
Arguments
:: [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.