Safe Haskell | Safe-Inferred |
---|
A Command
provides a mode of operation of your program.
This allows a single program to provide many different pieces of
functionality. The first argument to the program (or the first few, if it
has subcommands) determines which command should be executed.
(darcs
and cabal
are examples of programs with this behaviour.)
An Action
represents an IO action, together with information about
applicable options and non-option arguments.
Documentation
type Commands = Tree CommandSource
Commands s
is a tree of commands. It represents the whole set of
possible commands of a program.
data Tree a
Multi-way trees, also known as rose trees.
A Command
is an action, together with some descriptive information.
An Action
is an IO
action, which may take arguments
("non-options") and options from the command line.
withNonOption :: Type x -> (x -> Action) -> ActionSource
Create an action that takes an argument (non-option).
The type of argument is specified by the first parameter; such values can be obtained from the module System.Console.Argument.
withOption :: Option a -> (a -> Action) -> ActionSource
Create an action that takes an option.
The first parameter is a description of the option; such a value can be
constructed using option
.
ignoreOption :: Option a -> Action -> ActionSource
Create an action that allows, but ignores, the given option.
This is especially useful if this option is given in the configuration file, but is meant for other commands; then this action will not give an error message about an unrecognised option.