|
Distribution.Simple.Command | Portability | portable | Maintainer | cabal-devel@haskell.org |
|
|
|
|
|
Description |
This is to do with command line handling. The Cabal command line is
organised into a number of named sub-commands (much like darcs). The
CommandUI abstraction represents one of these sub-commands, with a name,
description, a set of flags. Commands can be associated with actions and
run. It handles some common stuff automatically, like the --help and
command line completion flags. It is designed to allow other tools make
derived commands. This feature is used heavily in cabal-install.
|
|
Synopsis |
|
|
|
|
Command interface
|
|
|
Constructors | CommandUI | | commandName :: String | The name of the command as it would be entered on the command line.
For example "build".
| commandSynopsis :: String | A short, one line description of the command to use in help texts.
| commandUsage :: String -> String | The useage line summary for this command
| commandDescription :: Maybe (String -> String) | Additional explanation of the command to use in help texts.
| commandDefaultFlags :: flags | Initial / empty flags
| commandOptions :: ShowOrParseArgs -> [OptionField flags] | All the Option fields for this command
|
|
|
|
|
|
Show flags in the standard long option command line format
|
|
Constructing commands
|
|
|
|
|
|
|
|
Associating actions with commands
|
|
|
|
|
|
|
Utility function, many commands do not accept additional flags. This
action fails with a helpful error message if the user supplies any extra.
|
|
Running commands
|
|
data CommandParse flags | Source |
|
Constructors | | Instances | |
|
|
|
|
Option Fields
|
|
|
We usually have a datatype for storing configuration values, where
every field stores a configuration option, and the user sets
the value either via command line flags or a configuration file.
An individual OptionField models such a field, and we usually
build a list of options associated to a configuration datatype.
| Constructors | |
|
|
|
|
Constructing Option Fields
|
|
|
Create an option taking a single OptDescr.
No explicit Name is given for the Option, the name is the first LFlag given.
|
|
|
:: Name | | -> get | | -> set | | -> [get -> set -> OptDescr a] | MkOptDescr constructors partially applied to flags and description.
| -> OptionField a | | Create an option taking several OptDescrs.
You will have to give the flags and description individually to the OptDescr constructor.
|
|
|
Liftings & Projections
|
|
|
|
|
to view as a FieldDescr, we sort the list of interfaces (Req > Bool > Choice > Opt) and consider only the first one.
|
|
Option Descriptions
|
|
|
An OptionField takes one or more OptDescrs, describing the command line interface for the field.
| Constructors | |
|
|
|
|
|
Short command line option strings
|
|
|
Long command line option strings
|
|
|
|
|
|
OptDescr smart constructors
|
|
|
|
|
Create a string-valued command line interface.
|
|
|
(String -> a) variant of reqArg
|
|
|
Create a string-valued command line interface with a default value.
|
|
|
(String -> a) variant of optArg
|
|
|
|
|
|
|
|
|
create a Choice option
|
|
|
create a Choice option out of an enumeration type.
As long flags, the Show output is used. As short flags, the first character
which does not conflict with a previous one is used.
|
|
Produced by Haddock version 2.6.1 |