cli: CLI

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

please see README.md


[Skip to Readme]

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

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 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 2019-01-05T08:35:49Z
Category cli
Home page https://github.com/vincenthz/hs-cli#readme
Uploaded by VincentHanquez at 2019-01-04T20:57:01Z
Distributions NixOS:0.2.0
Reverse Dependencies 1 direct, 0 indirect [details]
Executables example
Downloads 7190 total (25 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2019-01-04 [all 1 reports]

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.