options: Parsing command-line options
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.
Downloads
- options-0.1.1.tar.gz [browse] (Cabal source package)
- Package description (revised from the package)
Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
- No Candidates
| Versions [RSS] | 0.1, 0.1.1, 1.0, 1.1, 1.2, 1.2.1, 1.2.1.1, 1.2.1.2 |
|---|---|
| Dependencies | base (>=4.1 && <4.8), bytestring (>=0.9), containers (>=0.1), monads-tf (>=0.1), system-filepath (>=0.4 && <0.5), template-haskell (>=2.3), text (>=0.7), transformers (>=0.2) [details] |
| License | MIT |
| Author | John Millikin <jmillikin@gmail.com> |
| Maintainer | John Millikin <jmillikin@gmail.com> |
| Revised | Revision 1 made by HerbertValerioRiedel at 2014-12-29T11:22:12Z |
| Category | Console |
| Home page | https://john-millikin.com/software/haskell-options/ |
| Bug tracker | mailto:jmillikin@gmail.com |
| Source repo | head: bzr branch https://john-millikin.com/branches/haskell-options/0.1/ this: bzr branch https://john-millikin.com/branches/haskell-options/0.1/ -r haskell-options_0.1.1 |
| Uploaded | by JohnMillikin at 2012-04-08T20:57:20Z |
| Distributions | Arch:1.2.1.2, Debian:1.2.1.1, LTSHaskell:1.2.1.2, NixOS:1.2.1.2, Stackage:1.2.1.2 |
| Reverse Dependencies | 10 direct, 27 indirect [details] |
| Downloads | 12904 total (11 in the last 30 days) |
| Rating | (no votes yet) [estimated by Bayesian average] |
| Your Rating | |
| Status | Docs uploaded by user Build status unknown [no reports yet] |