ReadArgs-1.2.1: Simple command line argument parsing

Safe HaskellNone

ReadArgs

Synopsis

Documentation

readArgs :: ArgumentTuple a => IO aSource

parse the desired argument tuple from the command line or print a simple usage statment and quit

readArgsFrom :: ArgumentTuple a => [String] -> IO aSource

read args from the given strings or print a simple usage statment and quit (so you can do option parsing first)

class Arguable a whereSource

a class for types that can be parsed from exactly one command line argument

Methods

parse :: String -> Maybe aSource

name :: a -> StringSource

name's argument will usually be undefined, so when defining instances of Arguable, it should be lazy in its argument

Instances

Arguable Char

char is a special case, so that we don't force the user to single-quote their input

Arguable String

string is a special case, so that we don't force the user to double-quote their input

(Typeable t, Read t) => Arguable t

all types that are typeable and readable can be used as simple arguments

Arguable Text

Text is a special case, so that we don't force the user to double-quote their input

Arguable FilePath

FilePath is a special case, so that we don't force the user to double-quote their input

class Argument a whereSource

a class for types that can be parsed from some number of command line arguments

Methods

parseArg :: [String] -> [(a, [String])]Source

argName :: a -> StringSource

argName's argument will usually be undefined, so when defining instances of Arguable, it should be lazy in its argument

Instances

Argument String

make sure strings are handled as a separate type, not a list of chars

Arguable a => Argument a

use the arguable tyep to just parse a single argument

Arguable a => Argument [a]

use a list when it should be parsed from zero or more (greedily)

Arguable a => Argument (Maybe a)

use Maybe when it should be parsed from one or zero (greedily)

Argument (m a) => Argument (NonGreedy m a)

use NonGreedy when it should be parsed non-greedily (e.g. (NonGreedy xs :: NonGreedy [] Int, x :: Maybe Float) <- readArgs)

newtype NonGreedy m a Source

a wrapper type to indicate a non-greedy list or maybe

Constructors

NonGreedy 

Fields

unNonGreedy :: m a
 

Instances

Eq (m a) => Eq (NonGreedy m a) 
Show (m a) => Show (NonGreedy m a) 
Argument (m a) => Argument (NonGreedy m a)

use NonGreedy when it should be parsed non-greedily (e.g. (NonGreedy xs :: NonGreedy [] Int, x :: Maybe Float) <- readArgs)

class ArgumentTuple a whereSource

a class for tuples of types that can be parsed from the entire list of arguments

Methods

parseArgsFrom :: [String] -> Maybe aSource

usageFor :: a -> StringSource

usageFor's argument will usually be undefined, so when defining instances of Arguable, it should be lazy in its argument

Instances

ArgumentTuple ()

use () for no arguments

Argument a => ArgumentTuple a 
(Argument b, Argument a) => ArgumentTuple (b, a) 
(Argument a, ArgumentTuple y) => ArgumentTuple (:& a y) 
(Argument c, Argument b, Argument a) => ArgumentTuple (c, b, a) 
(Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (d, c, b, a) 
(Argument e, Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (e, d, c, b, a) 
(Argument f, Argument e, Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (f, e, d, c, b, a) 
(Argument g, Argument f, Argument e, Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (g, f, e, d, c, b, a) 
(Argument h, Argument g, Argument f, Argument e, Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (h, g, f, e, d, c, b, a) 
(Argument i, Argument h, Argument g, Argument f, Argument e, Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (i, h, g, f, e, d, c, b, a) 
(Argument j, Argument i, Argument h, Argument g, Argument f, Argument e, Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (j, i, h, g, f, e, d, c, b, a) 
(Argument k, Argument j, Argument i, Argument h, Argument g, Argument f, Argument e, Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (k, j, i, h, g, f, e, d, c, b, a) 
(Argument l, Argument k, Argument j, Argument i, Argument h, Argument g, Argument f, Argument e, Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (l, k, j, i, h, g, f, e, d, c, b, a) 
(Argument m, Argument l, Argument k, Argument j, Argument i, Argument h, Argument g, Argument f, Argument e, Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (m, l, k, j, i, h, g, f, e, d, c, b, a) 
(Argument n, Argument m, Argument l, Argument k, Argument j, Argument i, Argument h, Argument g, Argument f, Argument e, Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (n, m, l, k, j, i, h, g, f, e, d, c, b, a) 
(Argument o, Argument n, Argument m, Argument l, Argument k, Argument j, Argument i, Argument h, Argument g, Argument f, Argument e, Argument d, Argument c, Argument b, Argument a) => ArgumentTuple (o, n, m, l, k, j, i, h, g, f, e, d, c, b, a) 

data a :& b Source

use :& to construct arbitrary length tuples of any parsable arguments

Constructors

a :& b 

Instances

(Eq a, Eq b) => Eq (:& a b) 
(Show a, Show b) => Show (:& a b) 
(Argument a, ArgumentTuple y) => ArgumentTuple (:& a y)