ui-command-0.5.1: A framework for friendly commandline programs

UI.Command

Synopsis

Documentation

type App config = ReaderT (AppContext config) IOSource

appArgs :: Default config => App config [String]Source

Get the application arguments

appConfig :: Default config => App config configSource

Get the application config

data (Default opts, Default config) => Application opts config Source

It is often simpler to use the default implementation of Application, and override it with the details you choose to use. For example, an implementation of the ''hello'' command:

 hello = def {
         appName = "hello",
         appVersion = "0.1",
         appAuthors = ["Joe R. Hacker"],
         appBugEmail = "bugs@example.com",
         appShortDesc = "UI.Command example program",
         appLongDesc = longDesc,
         appCategories = ["Greetings", "Cat Math"],
         appSeeAlso = ["tractorgen"],
         appProject = "Haskell",
         appCmds = [world, times]
 }
 
 longDesc = "a demonstration program for the UI.Command framework."

Constructors

Application 

Fields

appName :: String

Name of the program

appVersion :: String

Software version

appBugEmail :: String

Email address to report bugs to

appAuthors :: [String]

Names of authors

appShortDesc :: String

One-line description of the command

appLongDesc :: String

Long description of the command

appCategories :: [String]

Categories to show in help text, in order of appearance

appProject :: String

Project that this command is part of

appSeeAlso :: [String]

Related commands

appCmds :: [Command config]

The actual commands

appOptions :: [OptDescr opts]

Union of all options accepted by the application's commands. Note that options '-h', -?, '--help', '-V', '--version' will be automatically added and handled by UI.Command

appProcessConfig :: config -> [opts] -> IO config

Function to process options

Instances

(Default opts, Default config) => Default (Application opts config) 

data Default config => Command config Source

It is often simpler to use the default implementation of Command, and override it with the details you choose to use. For example, an implementation of the ''hello world'' command:

 world = def {
         cmdName = "world",
         cmdHandler = worldHandler,
         cmdCategory = "Greetings",
         cmdShortDesc = "An implementation of the standard software greeting."
 }

 worldHandler = liftIO $ putStrLn "Hello world!"

Constructors

Command 

Fields

cmdName :: String

Name of the cmdcommand

cmdHandler :: App config ()

Handler

cmdCategory :: String

Category in this program's documentation

cmdSynopsis :: String

Synopsis

cmdShortDesc :: String

Short description

cmdExamples :: [(String, String)]
(example description, args)

Instances

Default config => Default (Command config) 

appMain :: Application () () -> IO ()Source

Main wrapper

 main = appMain hello

appMainWithOptions :: (Default opts, Default config) => Application opts config -> IO ()Source