BSD-3-Clause licensed by Vincent Hanquez, Nicolas Di Prima
Maintained by [email protected]
This version can be pinned in stack with:cli-0.1.2@sha256:930ce59f9cbba08539b7b7c86da3190becb09b367d8d15492e4884205bf08128,2129

Module documentation for 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)