cli: CLI

[ bsd3, cli, library, program ] [ Propose Tags ]

please see README.md


[Skip to Readme]
Versions [faq] 0.0.1, 0.0.2, 0.0.3, 0.0.4, 0.0.5, 0.1.0, 0.1.1, 0.1.2, 0.2.0
Dependencies base (>4.9 && <5), basement, cli, foundation [details]
License BSD-3-Clause
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
Revised Revision 1 made by HerbertValerioRiedel at Sat Jan 5 08:35:49 UTC 2019
Category cli
Home page https://github.com/vincenthz/hs-cli#readme
Uploaded by VincentHanquez at Fri Jan 4 20:57:01 UTC 2019
Distributions NixOS:0.2.0
Executables example
Downloads 3483 total (101 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2019-01-04 [all 1 reports]

Modules

[Index] [Quick Jump]

Downloads

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


Readme for cli-0.2.0

[back to package description]

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)

License

The source code of cli is available under the BSD 3-Clause license, see LICENSE for more information.