getopt-generics: Create command line interfaces with ease

[ bsd3, console, library, system ] [ Propose Tags ]

Create command line interfaces with ease


[Skip to Readme]
Versions [faq] 0.1, 0.1.1, 0.2, 0.3, 0.4, 0.4.1, 0.5, 0.6, 0.6.1, 0.6.2, 0.6.3, 0.7, 0.7.1, 0.7.1.1, 0.8, 0.9, 0.10, 0.10.0.1, 0.11, 0.11.0.1, 0.11.0.2, 0.11.0.3, 0.12, 0.13, 0.13.0.1, 0.13.0.2, 0.13.0.3
Dependencies base (==4.*), base-compat (>=0.8), base-orphans, generics-sop, tagged [details]
License BSD-3-Clause
Copyright Zalora South East Asia Pte Ltd
Author Linh Nguyen, Sönke Hahn
Maintainer linh.nguyen@zalora.com, soenke.hahn@zalora.com
Category Console, System
Home page https://github.com/zalora/getopt-generics#readme
Bug tracker https://github.com/zalora/getopt-generics/issues
Source repo head: git clone https://github.com/zalora/getopt-generics
Uploaded by SoenkeHahn at Sun Sep 27 12:08:43 UTC 2015
Distributions Debian:0.13.0.2, LTSHaskell:0.13.0.3, NixOS:0.13.0.3, Stackage:0.13.0.3
Downloads 10595 total (462 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2015-09-27 [all 1 reports]

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for getopt-generics-0.11

[back to package description]

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 ### -->