argparser-0.3.1: Command line parsing framework for console applications

Portabilityportable
Stabilityunstable
Maintainersimon.bergot@gmail.com
Safe HaskellSafe-Inferred

System.Console.ArgParser.QuickParams

Contents

Description

Collection of functions which are basically shortcuts of System.Console.EasyConsole.Params versions. If you cannot find a parameter fitting your needs, you should check this module.

Values provided to parsedBy and andBy should be created with the following functions. The types are inferred. ArgParser will use readMaybe to convert the arguments to haskell values, except for strings which will be passed unmodified.

Flags can be passed in long form (--foo) or short form (-f) You may also provide a prefix form such as --fo.

Mandatory parameters will fail if the argument is absent or invalid. Optional parameters only fail if the argument is invalid (ie foo passed as Int)

Note that single arg parameters need exactly one arg, and that multiple args parameters can have any number of args (0 included).

Synopsis

Parameters without args

boolFlagSource

Arguments

:: Key

flag key

-> FlagParam Bool 

A simple command line flag. The parsing function will return True if the flag is present, if the flag is provided to the command line, and False otherwise. For a key foo, the flag can either be --foo or -f

Parameters with one arg

Flags

reqFlagSource

Arguments

:: RawRead a 
=> Key

Flag name

-> StdArgParam a 

A mandatory flag argument parameter

optFlagSource

Arguments

:: RawRead a 
=> a

Default value

-> Key

Flag name

-> StdArgParam a 

An optional flag argument parameter

Positional

reqPosSource

Arguments

:: RawRead a 
=> Key

Param name

-> StdArgParam a 

A mandatory positional argument parameter

optPosSource

Arguments

:: RawRead a 
=> a

Default value

-> Key

Param name

-> StdArgParam a 

An optional positional argument parameter

Parameters with multiple args

Flags

reqFlagArgsSource

Arguments

:: RawRead a 
=> Key

Flag name

-> b

Initial value

-> (b -> a -> b)

Accumulation function

-> StdArgParam b 

A mandatory flag argument parameter taking multiple arguments

optFlagArgsSource

Arguments

:: RawRead a 
=> b

Default value

-> Key

Flag name

-> b

Initial value

-> (b -> a -> b)

Accumulation function

-> StdArgParam b 

An optional flag argument parameter taking multiple arguments

Positionnal

posArgsSource

Arguments

:: RawRead a 
=> Key

Param name

-> b

Initial value

-> (b -> a -> b)

Accumulation function

-> StdArgParam b 

A parameter consuming all the remaining positional parameters

RawRead class

class RawRead a Source

A typeclass used to define a way a converting string to specific types. It is similar to read. The main difference is that strings are parsed without quotes.

 rawRead "foo" :: Maybe String == Just "foo"