Popularity
4.1
Declining
Activity
0.0
Stable
6
1
2

Monthly Downloads: 40
Programming language: Haskell
License: BSD 3-clause "New" or "Revised" License
Tags: Console    

argparser alternatives and similar packages

Based on the "Console" category.
Alternatively, view argparser alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of argparser or a related project?

Add another 'Console' Package

README

ArgParser

Declarative & minimalist command line app framework for haskell

This framework is inspired by the argparse package found in python batteries.

This library provides a small combinator dsl to specify a parser for a datatype. Running the parser will automatically consume and convert command line arguments. Default special action such as help/usage are automatically built from the parser specification.

Here is a quick example. First, we need a datatype:

data MyTest = MyTest Int Int
  deriving (Show) -- we will print the values

Then, we define a parser:

myTestParser :: ParserSpec MyTest
myTestParser = MyTest
  `parsedBy` reqPos "pos1"
  `andBy` optPos 0 "pos2"

we can now run a MyTest -> IO () value. It will either perform the action with the parse result, or display an error message:

main = withParseResult myTestParser print

Building this app will produce an executable foo which will behave like this:

$ foo 1 2
MyTest 1 2
$ foo 3
MyTest 3 0
$ foo -h
foo
usage : foo pos1 [pos2] [-h] [--version]

mandatory arguments:
 pos1

optional arguments:
 pos2
 -h, --help                    show this help message and exit
 --version                     print the program version and exit

For more information, please visit http://hackage.haskell.org/package/argparser-0.3.2/docs/System-Console-ArgParser.html .