options-0.1.1: Parsing command-line options

The options package

The options package lets library and application developers easily work with command-line options.

The following example is a full program that can accept two options, --message and --quiet:

{-# LANGUAGE TemplateHaskell #-}

import Options

defineOptions "MainOptions" $ do
    stringOption "optMessage" "message" "Hello world!"
        "A message to show the user."
    boolOption "optQuiet" "quiet" False
        "Whether to be quiet."
 
main :: IO ()
main = runCommand $ \opts args -> do
    if optQuiet opts
        then return ()
        else putStrLn (optMessage opts)
$ ./hello
Hello world!
$ ./hello --message='ciao mondo'
ciao mondo
$ ./hello --quiet
$

In addition, this library will automatically create documentation options such as --help and --help-all:

$ ./hello --help
Help Options:
  -h, --help                  Show option summary.
  --help-all                  Show all help options.

Application Options:
  --message                   A message to show the user.
  --quiet                     Whether to be quiet.

Properties

Versions0.1, 0.1.1
Dependenciesbase (≥4.1 & <5.0), bytestring (≥0.9), containers (≥0.1), monads-tf (≥0.1), system-filepath (0.4.*), template-haskell (≥2.3), text (≥0.7), transformers (≥0.2)
LicenseMIT
AuthorJohn Millikin <jmillikin@gmail.com>
MaintainerJohn Millikin <jmillikin@gmail.com>
Stabilityexperimental
CategoryConsole
Home pagehttps://john-millikin.com/software/haskell-options/
Bug trackermailto:jmillikin@gmail.com
Source repositorybzr branch https://john-millikin.com/branches/haskell-options/0.1/
Upload dateSun Apr 8 20:57:20 UTC 2012
Uploaded byJohnMillikin
Built onghc-7.4
DistributionsDebian: 0.1.1

Modules

Downloads