Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Very simple command line interface option parser.
Only allows options of the form --key=value, with the form --key equal to --key=True.
A list of OptUsr describes the options and provides default values.
get_opt_arg
merges user and default values into a table with values for all options.
Synopsis
- type Opt = (String, String)
- type OptUsr = (String, String, String, String)
- opt_usr_rw_def :: [Opt] -> [OptUsr] -> [OptUsr]
- opt_plain :: OptUsr -> Opt
- opt_usr_help :: OptUsr -> String
- opt_help :: [OptUsr] -> String
- opt_get :: [Opt] -> String -> String
- opt_get_nil :: [Opt] -> String -> Maybe String
- opt_read :: Read t => [Opt] -> String -> t
- opt_param_parse :: String -> Opt
- opt_parse :: String -> Maybe Opt
- opt_set_parse :: [String] -> ([Opt], [String])
- opt_merge :: [Opt] -> [Opt] -> [Opt]
- opt_proc :: [OptUsr] -> [String] -> ([Opt], [String])
- type OptHelp = [String]
- opt_help_pp :: OptHelp -> [OptUsr] -> String
- opt_usage :: OptHelp -> [OptUsr] -> IO ()
- opt_error :: OptHelp -> [OptUsr] -> t
- opt_verify :: OptHelp -> [OptUsr] -> [Opt] -> IO ()
- opt_get_arg :: Bool -> OptHelp -> [OptUsr] -> IO ([Opt], [String])
- opt_param_set_parse :: String -> [Opt]
- opt_scan :: [String] -> String -> Maybe String
- opt_scan_def :: [String] -> (String, String) -> String
- opt_scan_read :: Read t => [String] -> (String, t) -> t
Documentation
opt_usr_help :: OptUsr -> String Source #
OptUsr to help string, indent is two spaces.
opt_get_nil :: [Opt] -> String -> Maybe String Source #
Variant that returns Nothing if the result is the empty string, else Just the result.
opt_param_parse :: String -> Opt Source #
Parse k or k=v string, else error.
opt_parse :: String -> Maybe Opt Source #
Parse option string of form "--opt" or "--key=value".
opt_parse "--opt" == Just ("opt","True") opt_parse "--key=value" == Just ("key","value")
opt_set_parse :: [String] -> ([Opt], [String]) Source #
Parse option sequence, collating options and non-options.
opt_set_parse (words "--a --b=c d") == ([("a","True"),("b","c")],["d"])
opt_verify :: OptHelp -> [OptUsr] -> [Opt] -> IO () Source #
Verify that all Opt have keys that are in OptUsr
opt_get_arg :: Bool -> OptHelp -> [OptUsr] -> IO ([Opt], [String]) Source #
opt_set_parse
and maybe opt_verify
and opt_merge
of getArgs
.
If arguments include -h or --help run opt_usage
opt_param_set_parse :: String -> [Opt] Source #
Parse param set, one parameter per line.
opt_param_set_parse "a\nb=c" == [("a","True"),("b","c")]