cmdargs-0.10.20: Command line argument processing

Safe Haskell | None
Language | Haskell2010

System.Console.CmdArgs.GetOpt

Description

This provides a compatiblity wrapper to the `System.Console.GetOpt` module in `base`. That module is essentially a Haskell port of the GNU `getopt` library.

Changes: The changes from `GetOpt` are listed in the documentation for each function.

Synopsis

- convert :: String -> [OptDescr a] -> Mode ([a], [String])
- getOpt :: ArgOrder a -> [OptDescr a] -> [String] -> ([a], [String], [String])
- getOpt' :: ArgOrder a -> [OptDescr a] -> [String] -> ([a], [String], [String], [String])
- usageInfo :: String -> [OptDescr a] -> String
- data ArgOrder a = Permute
- data OptDescr a = Option [Char] [String] (ArgDescr a) String
- data ArgDescr a
  - = NoArg a
  - | ReqArg (String -> a) String
  - | OptArg (Maybe String -> a) String

# Documentation

convert :: String -> [OptDescr a] -> Mode ([a], [String]) Source #

Given a help text and a list of option descriptions, generate a `Mode`.

getOpt :: ArgOrder a -> [OptDescr a] -> [String] -> ([a], [String], [String]) Source #

Process the command-line, and return the list of values that matched (and those that didn't). The arguments are:

- The order requirements (see `ArgOrder`)
- The option descriptions (see `OptDescr`)
- The actual command line arguments (presumably got from `getArgs`).

`getOpt` returns a triple consisting of the option arguments, a list of non-options, and a list of error messages.

Changes: The list of errors will contain at most one entry, and if an error is present then the other two lists will be empty.

getOpt' :: ArgOrder a -> [OptDescr a] -> [String] -> ([a], [String], [String], [String]) Source #

Changes: This is exactly the same as `getOpt`, but the 3rd element of the tuple (second last) will be an empty list.

usageInfo :: String -> [OptDescr a] -> String Source #

Return a string describing the usage of a command, derived from the header (first argument) and the options described by the second argument.

data ArgOrder a Source #

What to do with options following non-options.

Changes: Only `Permute` is allowed, both `RequireOrder` and `ReturnInOrder` have been removed.

Constructors

Permute |

#### Instances

Instances details

Functor ArgOrder Source # |
Instance details Defined in System.Console.CmdArgs.GetOpt Methods fmap :: (a -> b) -> ArgOrder a -> ArgOrder b (<$) :: a -> ArgOrder b -> ArgOrder a

data OptDescr a #

Constructors

Option [Char] [String] (ArgDescr a) String |

#### Instances

Instances details

Functor OptDescr |
Instance details Defined in System.Console.GetOpt Methods fmap :: (a -> b) -> OptDescr a -> OptDescr b (<$) :: a -> OptDescr b -> OptDescr a

data ArgDescr a #

Constructors

NoArg a |
ReqArg (String -> a) String |
OptArg (Maybe String -> a) String |

#### Instances

Instances details

Functor ArgDescr |
Instance details Defined in System.Console.GetOpt Methods fmap :: (a -> b) -> ArgDescr a -> ArgDescr b (<$) :: a -> ArgDescr b -> ArgDescr a