lambda-options: Declarative command-line parser with type-driven pattern matching.

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

Warnings:

Declarative command-line parser with type-driven pattern matching.


[Skip to Readme]

Properties

Versions 0.1.0.0, 0.2.0.0, 0.3.0.0, 0.4.0.0, 0.4.0.1, 0.4.0.2, 0.5.0.0, 0.5.1.0, 0.6.0.0, 0.7.0.0, 0.8.0.0, 0.9.0.0, 0.9.0.1, 0.9.1.0, 1.0.0.0, 1.0.1.0, 1.0.2.0, 1.1.0.0, 1.1.0.0, 1.1.0.1
Change log None available
Dependencies base (>=4.12.0.0 && <4.13), containers (>=0.6.0.1 && <0.7), funspection (>=1.0.0.0 && <1.1), mtl (>=2.2.2 && <2.3), read-bounded (>=0.1.1.2 && <0.2) [details]
License BSD-3-Clause
Author Thomas Eding
Maintainer Thomas Eding
Category Text
Home page https://github.com/thomaseding/lambda-options
Bug tracker https://github.com/thomaseding/lambda-options/issues
Uploaded by ThomasEding at 2019-12-12T16:58:55Z

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for lambda-options-1.1.0.0

[back to package description]

lambda-options-haskell

Declarative command line parser using type-driven pattern matching.

Homepage: https://github.com/thomaseding/lambda-options

Hackage: https://hackage.haskell.org/package/lambda-options


Basic example:

import qualified System.Environment as Env
import qualified Text.LambdaOptions as L

options :: L.Options (IO ())
options = do

  L.addOption
    (L.kw ["--help", "-h"]
    `L.text` "Display this help text.")
    $ do
      putStrLn "Usage:"
      putStrLn $ L.getHelpDescription options

  L.addOption
    (L.kw "--add"
    `L.argText` "X Y"
    `L.text` "Adds two Doubles and prints their sum.")
    $ \x y -> do
      print $ x + (y :: Double)

main :: IO ()
main = do
  args <- Env.getArgs
  case L.runOptions options args of
    Left e -> do
      putStrLn $ L.prettyOptionsError e
      putStrLn $ L.getHelpDescription options
    Right results -> do
      sequence_ results
>>> :main --add 3 0.14
3.14
>>> :main -h
Usage:
     --add X Y               Adds two Doubles and prints their sum.
 -h, --help                  Display this help text.
>>> :main --add 0 1 --add 2 four
Bad input for `--add' at index 3: `four'
     --add X Y               Adds two Doubles and prints their sum.
 -h, --help                  Display this help text.