-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Interprets the command line and a config file as commands and options -- -- This library provides an infrastructure to build command line -- programs. It provides the following features: -- --
-- T --ConT :: Name -> Type instance Configuration () module System.Console.Action -- | An Action s is an IO action, which may take -- arguments ("non-options") from the command line, and which may use a -- configuration of type s. data Action c -- | A simple action, taking no argument. simple :: IO () -> Action c -- | 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. withArgument :: Type x -> (x -> Action c) -> Action c -- | Create an action that depends on the program configuration (determined -- by the configuration file and command line arguments). usingConfiguration :: (c -> Action c) -> Action c -- | This is the main module of console-program. You can use it to build a -- console program, that parses the command line (and a configuration -- file), divides it into modes/commands, options and non-options, and -- executes the corresponding action from a tree of commands. -- -- The main function is execute; provided with a tree of commands -- and a default configuration, it can be used as the main -- function. -- -- A "mode" or "command" provides a mode of operation of your program. -- This allows a single executable 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 that make -- heavy use of modes.) -- -- Options can be given in a configuration file, and on the command line. -- Commands specify which options apply to them (the -- applicableOptions field). Such option descriptions can be -- created by System.Console.Argument.option. -- -- Options can have arguments, as in program --option=value, -- where value is the argument to option. These -- arguments have types, dictated by the particular option. These types -- are represented by a System.Console.Argument.Type. -- -- A command can have also non-option arguments (plain arguments). These -- also have types. Create such commands using the function -- System.Console.Action.withArgument. module System.Console.Command -- | Commands s is a tree of commands. It represents the whole set -- of possible commands of a program. type Commands setting = Tree (Command setting) -- | A Command s is an action, together with some descriptive -- information. The description, and lists of applicable options and -- non-options are used only to show usage information for the command. -- s is the type of settings that the action may use. data Command c Command :: String -> [String] -> [OptDescr (Either String (Setting c))] -> String -> Action c -> Command c -- | This determines which command is executed, depending on the command -- line. name :: Command c -> String -- | For usage info. applicableNonOptions :: Command c -> [String] -- | For usage info; also, the union of this field, over all commands in -- the command tree, determines which options will be recognised when -- parsing the configuration file and command line. applicableOptions :: Command c -> [OptDescr (Either String (Setting c))] -- | For usage info. description :: Command c -> String action :: Command c -> Action c -- | Load the configuration file (if present), and run the action given on -- the command line. You may use this function, with appropriate -- arguments, as your main function. -- -- Settings in the configuration file override the default configuration; -- settings on the command line override both. execute :: Configuration c => c -> Commands c -> IO () -- | Print usage info for the program to stdout. showUsage :: Commands c -> IO () instance Ord (OptDescr a) instance Eq (OptDescr a)