Popularity
8.6
Growing
Activity
2.4
Growing
42
12
3

Monthly Downloads: 659
Programming language: Haskell
License: BSD 3-clause "New" or "Revised" License
Tags: System     Console    
Latest version: v0.13

getopt-generics alternatives and similar packages

Based on the "Console" category

Do you think we are missing an alternative of getopt-generics or a related project?

Add another 'Console' Package

README

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:

<!--- ### Start "docs/Simple.hs" "module Simple where\n\n" (MarkDown Haskell) ### -->

import WithCli

main :: IO ()
main = withCli run

run :: String -> Int -> Bool -> IO ()
run s i b = print (s, i, b)

<!--- ### End ### -->

This is how the program behaves in a shell:

<!--- ### Start "docs/Simple.shell-protocol" "" (MarkDown 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

<!--- ### End ### -->