argparser-0.3.3: Command line parsing framework for console applications

Copyright(c) Simon Bergot
LicenseBSD3
Maintainersimon.bergot@gmail.com
Stabilityunstable
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell98

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

boolFlag Source

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

reqFlag Source

Arguments

:: RawRead a 
=> Key

Flag name

-> StdArgParam a 

A mandatory flag argument parameter

optFlag Source

Arguments

:: RawRead a 
=> a

Default value

-> Key

Flag name

-> StdArgParam a 

An optional flag argument parameter

Positional

reqPos Source

Arguments

:: RawRead a 
=> Key

Param name

-> StdArgParam a 

A mandatory positional argument parameter

optPos Source

Arguments

:: RawRead a 
=> a

Default value

-> Key

Param name

-> StdArgParam a 

An optional positional argument parameter

Parameters with multiple args

Flags

reqFlagArgs Source

Arguments

:: RawRead a 
=> Key

Flag name

-> b

Initial value

-> (b -> a -> b)

Accumulation function

-> StdArgParam b 

A mandatory flag argument parameter taking multiple arguments

optFlagArgs Source

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

posArgs Source

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"

Minimal complete definition

rawParse