Copyright | (c) Sven Panne 2002-2005 |
---|---|
License | BSD-style |
Safe Haskell | None |
Language | Haskell2010 |
Agda.Utils.GetOpt
Contents
Description
This module provides facilities for parsing the command-line options
in a standalone program. It is essentially a Haskell port of the GNU
getopt
library.
It is a fork of System.Console.GetOpt from the base package of GHC, written by Sven Panne.
We modify it to remove the "allow prefixes of long options" behavior.
Synopsis
- 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
- = RequireOrder
- | Permute
- | ReturnInOrder (String -> a)
- data OptDescr a = Option [Char] [String] (ArgDescr a) String
- data ArgDescr a
GetOpt
Arguments
:: ArgOrder a | non-option handling |
-> [OptDescr a] | option descriptors |
-> [String] | the command-line arguments |
-> ([a], [String], [String]) | (options, non-options, error messages) |
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.
Arguments
:: ArgOrder a | non-option handling |
-> [OptDescr a] | option descriptors |
-> [String] | the command-line arguments |
-> ([a], [String], [String], [String]) | (options, non-options, unrecognized, error messages) |
This is almost the same as getOpt
, but returns a quadruple
consisting of the option arguments, a list of non-options, a list of
unrecognized options, and a list of error messages.
Arguments
:: String | header |
-> [OptDescr a] | option descriptors |
-> String | nicely formatted description of options |
Return a string describing the usage of a command, derived from the header (first argument) and the options described by the second argument.
What to do with options following non-options.
Constructors
RequireOrder | no option processing after first non-option |
Permute | freely intersperse options and non-options |
ReturnInOrder (String -> a) | wrap non-options into options |
Each OptDescr
describes a single option.
The arguments to Option
are:
- list of short option characters
- list of long option strings (without "--")
- argument descriptor
- explanation of option for user
Constructors
Option | description of a single options: |