optparse-declarative-0.3.0: Declarative command line option parser

Safe HaskellNone
LanguageHaskell2010

Options.Declarative

Contents

Description

Declarative options parser

Synopsis

Command type

class IsCmd c Source

Command class

Minimal complete definition

runCmd

Instances

IsCmd Group 
(KnownSymbol placeholder, IsCmd c) => IsCmd (Arg placeholder [String] -> c) 
(KnownSymbol placeholder, IsCmd c) => IsCmd (Arg placeholder String -> c) 
(KnownSymbol shortNames, KnownSymbols longNames, KnownSymbol placeholder, KnownSymbol help, ArgRead a, IsCmd c) => IsCmd (Flag shortNames longNames placeholder help a -> c) 
KnownSymbol help => IsCmd (Cmd help ()) 

data Cmd help a Source

Command

Instances

Monad (Cmd help) 
Functor (Cmd help) 
Applicative (Cmd help) 
MonadIO (Cmd help) 
KnownSymbol help => IsCmd (Cmd help ()) 

logStr Source

Arguments

:: Int

Verbosity Level

-> String

Message

-> Cmd help () 

Output string when the verbosity level is greater than or equal to logLevel

getVerbosity :: Cmd help Int Source

Return the verbosity level ('--verbosity=n')

getLogger :: MonadIO m => Cmd a (Int -> String -> m ()) Source

Retrieve the logger function

Argument definition tools

class Option a where Source

Command line option

Associated Types

type Value a :: * Source

Type of the argument' value

Methods

get :: a -> Value a Source

Get the argument' value

Instances

Option (Arg _a a) 
ArgRead a => Option (Flag _a _b _c _d a) 

data Flag shortNames longNames placeholder help a Source

Named argument

Instances

(KnownSymbol shortNames, KnownSymbols longNames, KnownSymbol placeholder, KnownSymbol help, ArgRead a, IsCmd c) => IsCmd (Flag shortNames longNames placeholder help a -> c) 
ArgRead a => Option (Flag _a _b _c _d a) 
type Value (Flag _a _b _c _d a) = Unwrap a 

data Arg placeholder a Source

Unnamed argument

Instances

(KnownSymbol placeholder, IsCmd c) => IsCmd (Arg placeholder [String] -> c) 
(KnownSymbol placeholder, IsCmd c) => IsCmd (Arg placeholder String -> c) 
Option (Arg _a a) 
type Value (Arg _a a) = a 

Defining argment types

class ArgRead a where Source

Command line option's annotated types

Minimal complete definition

Nothing

Associated Types

type Unwrap a :: * Source

Type of the argument

Methods

unwrap :: a -> Unwrap a Source

Get the argument's value

argRead :: Maybe String -> Maybe a Source

Argument parser

needArg :: Proxy a -> Bool Source

Indicate this argument is mandatory

Instances

data Def defaultValue a Source

The argument which has defalut value

Instances

(KnownSymbol defaultValue, ArgRead a) => ArgRead (Def defaultValue a) 
type Unwrap (Def defaultValue a) = Unwrap a 

Subcommands support

data Group Source

Command group

Constructors

Group 

Fields

groupHelp :: String
 
groupCmds :: [SubCmd]
 

Instances

data SubCmd Source

Sub command

subCmd :: IsCmd c => String -> c -> SubCmd Source

Make a sub command

Run a command

run :: IsCmd c => String -> Maybe String -> c -> IO () Source

Run a command with specifying program name and version

run_ :: IsCmd c => c -> IO () Source

Run a command