cli: CLI

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

please see

[Skip to Readme]
Versions [RSS] [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 <>, Nicolas Di Prima <>
Author Vincent Hanquez <>, Nicolas Di Prima <>
Revised Revision 1 made by HerbertValerioRiedel at 2019-01-05T08:35:49Z
Category cli
Home page
Uploaded by VincentHanquez at 2019-01-04T20:57:01Z
Distributions NixOS:0.2.0
Executables example
Downloads 6610 total (8 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2019-01-04 [all 1 reports]


[Index] [Quick Jump]


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]


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)


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