@hackage getopt-generics0.11
Create command line interfaces with ease
Categories
License
BSD-3-Clause
Maintainer
linh.nguyen@zalora.com, soenke.hahn@zalora.com
Links
Versions
Installation
Dependencies (5)
- base >=4 && <5
- base-compat >=0.8
- base-orphans
- generics-sop
- tagged Show all…
Dependents (9)
@hackage/dead-code-detection, @hackage/acme-everything, @hackage/xls, @hackage/concurrency-benchmarks, @hackage/wai-make-assets, @hackage/unicode-data, Show all…
getopt-generics
Status
This library is experimental.
Usage
getopt-generics tries to make it very simple to create command line
interfaces. Here's an example:
import WithCli
main :: IO ()
main = withCli run
run :: String -> Int -> Bool -> IO ()
run s i b = print (s, i, b)
This is how the program behaves in a shell:
$ program foo 42 true
("foo",42,True)
$ program --help
program [OPTIONS] STRING INTEGER BOOL
-h --help show help and exit
$ program foo 42 bar
cannot parse as BOOL: bar
# exit-code 1
$ program
missing argument of type STRING
missing argument of type INTEGER
missing argument of type BOOL
# exit-code 1
$ program foo 42 yes bar
unknown argument: bar
# exit-code 1