Skip to content

soenkehahn/getopt-generics

Repository files navigation

getopt-generics

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

About

Create command line interfaces with ease

Resources

License

Stars

Watchers

Forks

Packages

No packages published