multiarg-0.30.0.2: Command lines for options that take multiple arguments

Safe HaskellSafe-Inferred
LanguageHaskell2010

Multiarg.Types

Description

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.

Synopsis

Documentation

data ArgSpec a Source

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

Instances

data OptSpec a Source

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.

Constructors

OptSpec [ShortName] [LongName] (ArgSpec a) 

Instances

optSpec Source

Arguments

:: [Char]

There is one character for each desired short option name. Each of these characters may not be a hyphen; otherwise, optSpec will apply error.

-> [String]

There is one string for each desired long option name. Each string:

  • cannot be empty;
  • must not begin with a hyphen; and
  • must not contain an equal sign.

Otherwise, optSpec will apply error.

-> 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.

data ShortName Source

A short option name.

shortName :: Char -> Maybe ShortName Source

Creates a short option name. Any character other than a single hyphen will succeed.

data LongName Source

A long option name.

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.

newtype Word Source

A word supplied by the user on the command line.

Constructors

Word String 

Instances

newtype OptName Source

The name of an option (either a short option name or a long option name).

newtype OptArg Source

An option argument.

Constructors

OptArg 

Instances

newtype ShortTail Source

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.

Constructors

ShortTail String 

isLong Source

Arguments

:: 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?

isShort :: Word -> Maybe (ShortName, ShortTail) Source

Is this an input word for a short argument?

splitShortTail :: ShortTail -> Maybe (ShortName, ShortTail) Source

If possible, splits a ShortTail into a short option name and a remaining tail.