Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Functions and types used by the Multiarg module. You don't have to worry about "breaking" anything by using this module. This module is separate from Multiarg only because it makes the documentation in that module cleaner, as that module should satisfy most use cases. Use this module if you want more control over error handling, or if you want to process arguments using pure functions rather than IO functions.
- limelineOutputToParsedCommandLine :: ([Either [Output a] (PosArg a)], Maybe OptName) -> ParsedCommandLine a
- data ParsedCommandLine a = ParsedCommandLine [Either OptionError a] (Maybe OptName)
- parsedResults :: ParsedCommandLine a -> Either (String, [String]) [a]
- insufficientOptArgs :: OptName -> String
- optError :: OptionError -> String
- parseCommandLinePure :: [OptSpec a] -> (String -> a) -> [String] -> ParsedCommandLine a
- parseCommandLine :: (String -> String) -> [OptSpec a] -> (String -> a) -> IO [a]
- parseCommandLineHelp :: [OptSpec a] -> (String -> a) -> [String] -> ParsedCommandLine (Maybe a)
Documentation
limelineOutputToParsedCommandLine :: ([Either [Output a] (PosArg a)], Maybe OptName) -> ParsedCommandLine a Source
data ParsedCommandLine a Source
Indicates the result of parsing a command line.
ParsedCommandLine [Either OptionError a] (Maybe OptName) |
|
Functor ParsedCommandLine | |
Eq a => Eq (ParsedCommandLine a) | |
Ord a => Ord (ParsedCommandLine a) | |
Show a => Show (ParsedCommandLine a) |
parsedResults :: ParsedCommandLine a -> Either (String, [String]) [a] Source
optError :: OptionError -> String Source
:: [OptSpec a] | All program options |
-> (String -> a) | Processes non-option positional arguments |
-> [String] | Input tokens from the command line, probably obtained from
|
-> ParsedCommandLine a |
Parses a command line; a pure function (unlike
parseCommandLineIO
).
:: (String -> String) | Returns help for your command. This function is applied to the
name of the program being run, which is obtained from
|
-> [OptSpec a] | All program options. An option for |
-> (String -> a) | Processes positional arguments. |
-> IO [a] | Fetches the words from the command line arguments using
|
Parses a command line. Runs in the IO monad so that it can do some tedious things for you:
- fetches the words on command line using
getArgs
and the name of the program withgetProgName
- prints help, if the user requested help, and exits successfully
- prints an error message and exits unsuccessfully, if the user entered a bad command line (such as an unknown option)
If you don't want this degree of automation or if you want a pure
function, see the parseCommandLinePure
function in the
Multiarg.Internal module.
parseCommandLineHelp :: [OptSpec a] -> (String -> a) -> [String] -> ParsedCommandLine (Maybe a) Source
Automatically adds a short option, -h
, and a long option,
--help
. Intended primarily for use by the parseCommandLineIO
function.