cmdtheline-0.2.3: Declarative command-line option parsing and documentation library.

Safe HaskellSafe-Inferred

System.Console.CmdTheLine.Term

Contents

Synopsis

Evaluating Terms

Simple command line programs

eval :: [String] -> (Term a, TermInfo) -> IO aSource

eval args ( term, termInfo ) allows the user to pass args directly to the evaluation mechanism. This is useful if some kind of pre-processing is required. If you do not need to pre-process command line arguments, use one of exec or run. On failure the program exits.

exec :: (Term a, TermInfo) -> IO aSource

exec ( term, termInfo ) executes a command line program, directly grabbing the command line arguments from the environment and returning the result upon successful evaluation of term. On failure the program exits.

run :: (Term (IO a), TermInfo) -> IO aSource

run ( term, termInfo ) runs a term containing an IO action, performs the action, and returns the result on success. On failure the program exits.

unwrap :: [String] -> (Term a, TermInfo) -> IO (Either EvalExit a)Source

unwrap args ( term, termInfo ) unwraps a Term without handling errors. The intent is for use in testing of Terms where the programmer would like to consult error state without the program exiting.

Multi-command command line programs

evalChoice :: [String] -> (Term a, TermInfo) -> [(Term a, TermInfo)] -> IO aSource

evalChoice args mainTerm choices is analogous to eval, but for programs that provide a choice of commands.

execChoice :: (Term a, TermInfo) -> [(Term a, TermInfo)] -> IO aSource

Analogous to exec, but for programs that provide a choice of commands.

runChoice :: (Term (IO a), TermInfo) -> [(Term (IO a), TermInfo)] -> IO aSource

Analogous to run, but for programs that provide a choice of commands.

unwrapChoice :: [String] -> (Term a, TermInfo) -> [(Term a, TermInfo)] -> IO (Either EvalExit a)Source

Analogous to unwrap, but for programs that provide a choice of commands.

Exit information for testing

data EvalExit Source

Information about the way a Term exited early. Obtained by either unwraping or unwrapChoiceing some Term. Handy for testing programs when it is undesirable to exit execution of the entire program when a Term exits early.

Instances