The cli package

[Tags:bsd3, library, test]

All you need for interacting with users at the Console level


[Skip to Readme]

Properties

Versions 0.0.1, 0.0.2, 0.0.3, 0.0.4, 0.0.5, 0.1.0, 0.1.1, 0.1.2
Dependencies base (==4.*), mtl, terminfo, transformers [details]
License BSD3
Copyright Vincent Hanquez <vincent@snarc.org>, Nicolas Di Prima <nicolas@di-prima.fr>
Author Vincent Hanquez <vincent@snarc.org>, Nicolas Di Prima <nicolas@di-prima.fr>
Maintainer vincent@snarc.org
Category cli
Home page https://github.com/vincenthz/hs-cli
Bug tracker https://github.com/vincenthz/hs-cli/issues
Source repository head: git clone https://github.com/vincenthz/hs-cli
Uploaded Tue Feb 16 08:25:44 UTC 2016 by VincentHanquez
Distributions LTSHaskell:0.1.2, NixOS:0.1.2, Stackage:0.1.2, Tumbleweed:0.1.2
Downloads 1054 total (12 in the last 30 days)
Votes
0 []
Status Docs available [build log]
Last success reported on 2016-02-16 [all 1 reports]
Hackage Matrix CI

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees

Readme for cli

Readme for cli-0.1.2

cli

Build Status BSD Haskell

Documentation: cli on hackage

Option parser in DSL form, and display utilities for command line interfaces.

Option Parsing

Basic program looks like:

defaultMain $ do
    f1 <- flag ..
    f2 <- argument ..
    action $ \toParam ->
        something (toParam f1) (toParam f2) ..

with subcommands:

defaultMain $ do
    subcommand "foo" $ do
       <..flags & parameters definitions...>
       action $ \toParam -> <..IO-action..>
    subcommand "bar" $ do
       <..flags & parameters definitions...>
       action $ \toParam -> <..IO-action..>

A Real Example:

main = defaultMain $ do
    programName "test-cli"
    programDescription "test CLI program"
    flagA    <- flag $ FlagShort 'a' <> FlagLong "aaa"
    allArgs  <- remainingArguments "FILE"
    action $ \toParam -> do
        putStrLn $ "using flag A : " ++ show (toParam flagA)
        putStrLn $ "args: " ++ show (toParam allArgs)