Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Types used throughout Multiarg, and associated functions. Ordinarily you should not need this module; Multiarg and Multiarg.Mode export all the types and constructors you should ordinarily need. However, if you want more control than those modules afford, you can import this one.
- data ArgSpec a
- data OptSpec a = OptSpec [ShortName] [LongName] (ArgSpec a)
- optSpec :: [Char] -> [String] -> ArgSpec a -> OptSpec a
- data ShortName
- shortNameToChar :: ShortName -> Char
- shortName :: Char -> Maybe ShortName
- data LongName
- longNameToString :: LongName -> String
- longName :: String -> Maybe LongName
- newtype Word = Word String
- newtype OptName = OptName (Either ShortName LongName)
- optNameToString :: OptName -> String
- newtype OptArg = OptArg {}
- newtype ShortTail = ShortTail String
- isLong :: Word -> Maybe (LongName, Maybe OptArg)
- isShort :: Word -> Maybe (ShortName, ShortTail)
- wordToOptArg :: Word -> OptArg
- splitShortTail :: ShortTail -> Maybe (ShortName, ShortTail)
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
.
shortNameToChar :: ShortName -> Char Source
shortName :: Char -> Maybe ShortName Source
Creates a short option name. Any character other than a single hyphen will succeed.
longNameToString :: LongName -> String Source
longName :: String -> Maybe LongName Source
Creates a long option name. The string may not be empty, and the first character may not be a hyphen. In addition, no character may be an equal sign.
A word supplied by the user on the command line.
The name of an option (either a short option name or a long option name).
optNameToString :: OptName -> String Source
An option argument.
Characters after the first short option name in a flag that
specifies a short option instance, if the user supplies
-afoobar
, then this will be foobar
.
:: Word | |
-> Maybe (LongName, Maybe OptArg) | Nothing if the option does not begin with a double dash and is not at least three characters long. Otherwise, returns the characters following the double dash to the left of any equal sign. The Maybe in the tuple is Nothing if there is no equal sign, or Just followed by characters following the equal sign if there is one. |
Is this word an input for a long option?
wordToOptArg :: Word -> OptArg Source