MissingH-1.1.0.2: Large utility librarySource codeContentsIndex
System.Console.GetOpt.Utils
Portabilityportable
Stabilityprovisional
MaintainerJohn Goerzen <jgoerzen@complete.org>
Description

Written by John Goerzen, jgoerzen@complete.org

Utilities for command-line parsing, including wrappers around the standard System.Console.GetOpt module.

Synopsis
parseCmdLine :: ArgOrder a -> [OptDescr a] -> String -> IO ([a], [String])
validateCmdLine :: ArgOrder a -> [OptDescr a] -> String -> (([a], [String]) -> Maybe String) -> IO ([a], [String])
type StdOption = (String, String)
stdRequired :: String -> String -> StdOption
stdOptional :: String -> Maybe String -> StdOption
Documentation
parseCmdLine :: ArgOrder a -> [OptDescr a] -> String -> IO ([a], [String])Source

Simple command line parser -- a basic wrapper around the system's default getOpt. See the System.Console.GetOpt manual for a description of the first two parameters.

The third parameter is a usage information header.

The return value consists of the list of parsed flags and a list of non-option arguments.

validateCmdLine :: ArgOrder a -> [OptDescr a] -> String -> (([a], [String]) -> Maybe String) -> IO ([a], [String])Source

Similar to parseCmdLine, but takes an additional function that validates the post-parse command-line arguments. This is useful, for example, in situations where there are two arguments that are mutually-exclusive and only one may legitimately be given at a time.

The return value of the function indicates whether or not it detected an error condition. If it returns Nothing, there is no error. If it returns Just String, there was an error, described by the String.

type StdOption = (String, String)Source

A type to standardize some common uses of GetOpt.

The first component of the tuple is the long name of the option.

The second component is empty if there is no arg, or has the arg otherwise.

stdRequiredSource
:: StringName of arg
-> String
-> StdOption
Handle a required argument.
stdOptionalSource
:: StringName of arg
-> Maybe String
-> StdOption
Handle an optional argument.
Produced by Haddock version 2.6.0