<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Distribution.Simple.Command</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[ window.onload = function () {pageLoad();setSynopsis("mini_Distribution-Simple-Command.html");}; //]]> </script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">Cabal-1.14.0: A framework for packaging Haskell software</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Portability</th><td>portable</td></tr><tr><th>Maintainer</th><td>cabal-devel@haskell.org</td></tr><tr><th>Safe Haskell</th><td>None</td></tr></table><p class="caption">Distribution.Simple.Command</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Command interface </a><ul><li><a href="#g:2">Constructing commands </a></li><li><a href="#g:3">Associating actions with commands </a></li><li><a href="#g:4">Running commands </a></li></ul></li><li><a href="#g:5">Option Fields </a><ul><li><a href="#g:6">Constructing Option Fields </a></li><li><a href="#g:7">Liftings & Projections </a></li></ul></li><li><a href="#g:8">Option Descriptions </a><ul><li><a href="#g:9">OptDescr <code>smart</code> constructors </a></li></ul></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>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 <code><a href="Distribution-Simple-Command.html#t:CommandUI">CommandUI</a></code> 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 <code>--help</code> and command line completion flags. It is designed to allow other tools make derived commands. This feature is used heavily in <code>cabal-install</code>. </p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><span class="keyword">data</span> <a href="#t:CommandUI">CommandUI</a> flags = <a href="#v:CommandUI">CommandUI</a> {<ul class="subs"><li><a href="#v:commandName">commandName</a> :: <a href="../base-4.5.1.0/Data-String.html#t:String">String</a></li><li><a href="#v:commandSynopsis">commandSynopsis</a> :: <a href="../base-4.5.1.0/Data-String.html#t:String">String</a></li><li><a href="#v:commandUsage">commandUsage</a> :: <a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a></li><li><a href="#v:commandDescription">commandDescription</a> :: <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> (<a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a>)</li><li><a href="#v:commandDefaultFlags">commandDefaultFlags</a> :: flags</li><li><a href="#v:commandOptions">commandOptions</a> :: <a href="Distribution-Simple-Command.html#t:ShowOrParseArgs">ShowOrParseArgs</a> -> [<a href="Distribution-Simple-Command.html#t:OptionField">OptionField</a> flags]</li></ul>}</li><li class="src short"><a href="#v:commandShowOptions">commandShowOptions</a> :: <a href="Distribution-Simple-Command.html#t:CommandUI">CommandUI</a> flags -> flags -> [<a href="../base-4.5.1.0/Data-String.html#t:String">String</a>]</li><li class="src short"><span class="keyword">data</span> <a href="#t:CommandParse">CommandParse</a> flags<ul class="subs"><li>= <a href="#v:CommandHelp">CommandHelp</a> (<a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a>) </li><li>| <a href="#v:CommandList">CommandList</a> [<a href="../base-4.5.1.0/Data-String.html#t:String">String</a>] </li><li>| <a href="#v:CommandErrors">CommandErrors</a> [<a href="../base-4.5.1.0/Data-String.html#t:String">String</a>] </li><li>| <a href="#v:CommandReadyToGo">CommandReadyToGo</a> flags </li></ul></li><li class="src short"><a href="#v:commandParseArgs">commandParseArgs</a> :: <a href="Distribution-Simple-Command.html#t:CommandUI">CommandUI</a> flags -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a> -> [<a href="../base-4.5.1.0/Data-String.html#t:String">String</a>] -> <a href="Distribution-Simple-Command.html#t:CommandParse">CommandParse</a> (flags -> flags, [<a href="../base-4.5.1.0/Data-String.html#t:String">String</a>])</li><li class="src short"><span class="keyword">data</span> <a href="#t:ShowOrParseArgs">ShowOrParseArgs</a> <ul class="subs"><li>= <a href="#v:ShowArgs">ShowArgs</a> </li><li>| <a href="#v:ParseArgs">ParseArgs</a> </li></ul></li><li class="src short"><a href="#v:makeCommand">makeCommand</a> :: <a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> (<a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a>) -> flags -> (<a href="Distribution-Simple-Command.html#t:ShowOrParseArgs">ShowOrParseArgs</a> -> [<a href="Distribution-Simple-Command.html#t:OptionField">OptionField</a> flags]) -> <a href="Distribution-Simple-Command.html#t:CommandUI">CommandUI</a> flags</li><li class="src short"><span class="keyword">data</span> <a href="#t:Command">Command</a> action</li><li class="src short"><a href="#v:commandAddAction">commandAddAction</a> :: <a href="Distribution-Simple-Command.html#t:CommandUI">CommandUI</a> flags -> (flags -> [<a href="../base-4.5.1.0/Data-String.html#t:String">String</a>] -> action) -> <a href="Distribution-Simple-Command.html#t:Command">Command</a> action</li><li class="src short"><a href="#v:noExtraFlags">noExtraFlags</a> :: [<a href="../base-4.5.1.0/Data-String.html#t:String">String</a>] -> <a href="../base-4.5.1.0/System-IO.html#t:IO">IO</a> ()</li><li class="src short"><a href="#v:commandsRun">commandsRun</a> :: <a href="Distribution-Simple-Command.html#t:CommandUI">CommandUI</a> a -> [<a href="Distribution-Simple-Command.html#t:Command">Command</a> action] -> [<a href="../base-4.5.1.0/Data-String.html#t:String">String</a>] -> <a href="Distribution-Simple-Command.html#t:CommandParse">CommandParse</a> (a, <a href="Distribution-Simple-Command.html#t:CommandParse">CommandParse</a> action)</li><li class="src short"><span class="keyword">data</span> <a href="#t:OptionField">OptionField</a> a = <a href="#v:OptionField">OptionField</a> {<ul class="subs"><li><a href="#v:optionName">optionName</a> :: <a href="Distribution-Simple-Command.html#t:Name">Name</a></li><li><a href="#v:optionDescr">optionDescr</a> :: [<a href="Distribution-Simple-Command.html#t:OptDescr">OptDescr</a> a]</li></ul>}</li><li class="src short"><span class="keyword">type</span> <a href="#t:Name">Name</a> = <a href="../base-4.5.1.0/Data-String.html#t:String">String</a></li><li class="src short"><a href="#v:option">option</a> :: <a href="Distribution-Simple-Command.html#t:SFlags">SFlags</a> -> <a href="Distribution-Simple-Command.html#t:LFlags">LFlags</a> -> <a href="Distribution-Simple-Command.html#t:Description">Description</a> -> get -> set -> <a href="Distribution-Simple-Command.html#t:MkOptDescr">MkOptDescr</a> get set a -> <a href="Distribution-Simple-Command.html#t:OptionField">OptionField</a> a</li><li class="src short"><a href="#v:multiOption">multiOption</a> :: <a href="Distribution-Simple-Command.html#t:Name">Name</a> -> get -> set -> [get -> set -> <a href="Distribution-Simple-Command.html#t:OptDescr">OptDescr</a> a] -> <a href="Distribution-Simple-Command.html#t:OptionField">OptionField</a> a</li><li class="src short"><a href="#v:liftOption">liftOption</a> :: (b -> a) -> (a -> b -> b) -> <a href="Distribution-Simple-Command.html#t:OptionField">OptionField</a> a -> <a href="Distribution-Simple-Command.html#t:OptionField">OptionField</a> b</li><li class="src short"><a href="#v:viewAsFieldDescr">viewAsFieldDescr</a> :: <a href="Distribution-Simple-Command.html#t:OptionField">OptionField</a> a -> <a href="Distribution-ParseUtils.html#t:FieldDescr">FieldDescr</a> a</li><li class="src short"><span class="keyword">data</span> <a href="#t:OptDescr">OptDescr</a> a<ul class="subs"><li>= <a href="#v:ReqArg">ReqArg</a> <a href="Distribution-Simple-Command.html#t:Description">Description</a> <a href="Distribution-Simple-Command.html#t:OptFlags">OptFlags</a> <a href="Distribution-Simple-Command.html#t:ArgPlaceHolder">ArgPlaceHolder</a> (<a href="Distribution-ReadE.html#t:ReadE">ReadE</a> (a -> a)) (a -> [<a href="../base-4.5.1.0/Data-String.html#t:String">String</a>]) </li><li>| <a href="#v:OptArg">OptArg</a> <a href="Distribution-Simple-Command.html#t:Description">Description</a> <a href="Distribution-Simple-Command.html#t:OptFlags">OptFlags</a> <a href="Distribution-Simple-Command.html#t:ArgPlaceHolder">ArgPlaceHolder</a> (<a href="Distribution-ReadE.html#t:ReadE">ReadE</a> (a -> a)) (a -> a) (a -> [<a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a>]) </li><li>| <a href="#v:ChoiceOpt">ChoiceOpt</a> [(<a href="Distribution-Simple-Command.html#t:Description">Description</a>, <a href="Distribution-Simple-Command.html#t:OptFlags">OptFlags</a>, a -> a, a -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>)] </li><li>| <a href="#v:BoolOpt">BoolOpt</a> <a href="Distribution-Simple-Command.html#t:Description">Description</a> <a href="Distribution-Simple-Command.html#t:OptFlags">OptFlags</a> <a href="Distribution-Simple-Command.html#t:OptFlags">OptFlags</a> (<a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a> -> a -> a) (a -> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>) </li></ul></li><li class="src short"><span class="keyword">type</span> <a href="#t:Description">Description</a> = <a href="../base-4.5.1.0/Data-String.html#t:String">String</a></li><li class="src short"><span class="keyword">type</span> <a href="#t:SFlags">SFlags</a> = [<a href="../base-4.5.1.0/Data-Char.html#t:Char">Char</a>]</li><li class="src short"><span class="keyword">type</span> <a href="#t:LFlags">LFlags</a> = [<a href="../base-4.5.1.0/Data-String.html#t:String">String</a>]</li><li class="src short"><span class="keyword">type</span> <a href="#t:OptFlags">OptFlags</a> = (<a href="Distribution-Simple-Command.html#t:SFlags">SFlags</a>, <a href="Distribution-Simple-Command.html#t:LFlags">LFlags</a>)</li><li class="src short"><span class="keyword">type</span> <a href="#t:ArgPlaceHolder">ArgPlaceHolder</a> = <a href="../base-4.5.1.0/Data-String.html#t:String">String</a></li><li class="src short"><span class="keyword">type</span> <a href="#t:MkOptDescr">MkOptDescr</a> get set a = <a href="Distribution-Simple-Command.html#t:SFlags">SFlags</a> -> <a href="Distribution-Simple-Command.html#t:LFlags">LFlags</a> -> <a href="Distribution-Simple-Command.html#t:Description">Description</a> -> get -> set -> <a href="Distribution-Simple-Command.html#t:OptDescr">OptDescr</a> a</li><li class="src short"><a href="#v:reqArg">reqArg</a> :: <a href="../base-4.5.1.0/Data-Monoid.html#t:Monoid">Monoid</a> b => <a href="Distribution-Simple-Command.html#t:ArgPlaceHolder">ArgPlaceHolder</a> -> <a href="Distribution-ReadE.html#t:ReadE">ReadE</a> b -> (b -> [<a href="../base-4.5.1.0/Data-String.html#t:String">String</a>]) -> <a href="Distribution-Simple-Command.html#t:MkOptDescr">MkOptDescr</a> (a -> b) (b -> a -> a) a</li><li class="src short"><a href="#v:reqArg-39-">reqArg'</a> :: <a href="../base-4.5.1.0/Data-Monoid.html#t:Monoid">Monoid</a> b => <a href="Distribution-Simple-Command.html#t:ArgPlaceHolder">ArgPlaceHolder</a> -> (<a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> b) -> (b -> [<a href="../base-4.5.1.0/Data-String.html#t:String">String</a>]) -> <a href="Distribution-Simple-Command.html#t:MkOptDescr">MkOptDescr</a> (a -> b) (b -> a -> a) a</li><li class="src short"><a href="#v:optArg">optArg</a> :: <a href="../base-4.5.1.0/Data-Monoid.html#t:Monoid">Monoid</a> b => <a href="Distribution-Simple-Command.html#t:ArgPlaceHolder">ArgPlaceHolder</a> -> <a href="Distribution-ReadE.html#t:ReadE">ReadE</a> b -> b -> (b -> [<a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a>]) -> <a href="Distribution-Simple-Command.html#t:MkOptDescr">MkOptDescr</a> (a -> b) (b -> a -> a) a</li><li class="src short"><a href="#v:optArg-39-">optArg'</a> :: <a href="../base-4.5.1.0/Data-Monoid.html#t:Monoid">Monoid</a> b => <a href="Distribution-Simple-Command.html#t:ArgPlaceHolder">ArgPlaceHolder</a> -> (<a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> b) -> (b -> [<a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a>]) -> <a href="Distribution-Simple-Command.html#t:MkOptDescr">MkOptDescr</a> (a -> b) (b -> a -> a) a</li><li class="src short"><a href="#v:noArg">noArg</a> :: (<a href="../base-4.5.1.0/Data-Eq.html#t:Eq">Eq</a> b, <a href="../base-4.5.1.0/Data-Monoid.html#t:Monoid">Monoid</a> b) => b -> <a href="Distribution-Simple-Command.html#t:MkOptDescr">MkOptDescr</a> (a -> b) (b -> a -> a) a</li><li class="src short"><a href="#v:boolOpt">boolOpt</a> :: (b -> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>) -> (<a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a> -> b) -> <a href="Distribution-Simple-Command.html#t:SFlags">SFlags</a> -> <a href="Distribution-Simple-Command.html#t:SFlags">SFlags</a> -> <a href="Distribution-Simple-Command.html#t:MkOptDescr">MkOptDescr</a> (a -> b) (b -> a -> a) a</li><li class="src short"><a href="#v:boolOpt-39-">boolOpt'</a> :: (b -> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>) -> (<a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a> -> b) -> <a href="Distribution-Simple-Command.html#t:OptFlags">OptFlags</a> -> <a href="Distribution-Simple-Command.html#t:OptFlags">OptFlags</a> -> <a href="Distribution-Simple-Command.html#t:MkOptDescr">MkOptDescr</a> (a -> b) (b -> a -> a) a</li><li class="src short"><a href="#v:choiceOpt">choiceOpt</a> :: <a href="../base-4.5.1.0/Data-Eq.html#t:Eq">Eq</a> b => [(b, <a href="Distribution-Simple-Command.html#t:OptFlags">OptFlags</a>, <a href="Distribution-Simple-Command.html#t:Description">Description</a>)] -> <a href="Distribution-Simple-Command.html#t:MkOptDescr">MkOptDescr</a> (a -> b) (b -> a -> a) a</li><li class="src short"><a href="#v:choiceOptFromEnum">choiceOptFromEnum</a> :: (<a href="../base-4.5.1.0/Prelude.html#t:Bounded">Bounded</a> b, <a href="../base-4.5.1.0/Prelude.html#t:Enum">Enum</a> b, <a href="../base-4.5.1.0/Text-Show.html#t:Show">Show</a> b, <a href="../base-4.5.1.0/Data-Eq.html#t:Eq">Eq</a> b) => <a href="Distribution-Simple-Command.html#t:MkOptDescr">MkOptDescr</a> (a -> b) (b -> a -> a) a</li></ul></div><div id="interface"><h1 id="g:1">Command interface </h1><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:CommandUI" class="def">CommandUI</a> flags </p><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:CommandUI" class="def">CommandUI</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div class="subs fields"><p class="caption">Fields</p><dl><dt class="src"><a name="v:commandName" class="def">commandName</a> :: <a href="../base-4.5.1.0/Data-String.html#t:String">String</a></dt><dd class="doc"><p>The name of the command as it would be entered on the command line. For example <code>"build"</code>. </p></dd><dt class="src"><a name="v:commandSynopsis" class="def">commandSynopsis</a> :: <a href="../base-4.5.1.0/Data-String.html#t:String">String</a></dt><dd class="doc"><p>A short, one line description of the command to use in help texts. </p></dd><dt class="src"><a name="v:commandUsage" class="def">commandUsage</a> :: <a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a></dt><dd class="doc"><p>The useage line summary for this command </p></dd><dt class="src"><a name="v:commandDescription" class="def">commandDescription</a> :: <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> (<a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a>)</dt><dd class="doc"><p>Additional explanation of the command to use in help texts. </p></dd><dt class="src"><a name="v:commandDefaultFlags" class="def">commandDefaultFlags</a> :: flags</dt><dd class="doc"><p>Initial / empty flags </p></dd><dt class="src"><a name="v:commandOptions" class="def">commandOptions</a> :: <a href="Distribution-Simple-Command.html#t:ShowOrParseArgs">ShowOrParseArgs</a> -> [<a href="Distribution-Simple-Command.html#t:OptionField">OptionField</a> flags]</dt><dd class="doc"><p>All the Option fields for this command </p></dd></dl><div class="clear"></div></div></td></tr></table></div></div><div class="top"><p class="src"><a name="v:commandShowOptions" class="def">commandShowOptions</a> :: <a href="Distribution-Simple-Command.html#t:CommandUI">CommandUI</a> flags -> flags -> [<a href="../base-4.5.1.0/Data-String.html#t:String">String</a>]</p><div class="doc"><p>Show flags in the standard long option command line format </p></div></div><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:CommandParse" class="def">CommandParse</a> flags </p><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:CommandHelp" class="def">CommandHelp</a> (<a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a>)</td><td class="doc empty"> </td></tr><tr><td class="src"><a name="v:CommandList" class="def">CommandList</a> [<a href="../base-4.5.1.0/Data-String.html#t:String">String</a>]</td><td class="doc empty"> </td></tr><tr><td class="src"><a name="v:CommandErrors" class="def">CommandErrors</a> [<a href="../base-4.5.1.0/Data-String.html#t:String">String</a>]</td><td class="doc empty"> </td></tr><tr><td class="src"><a name="v:CommandReadyToGo" class="def">CommandReadyToGo</a> flags</td><td class="doc empty"> </td></tr></table></div><div class="subs instances"><p id="control.i:CommandParse" class="caption collapser" onclick="toggleSection('i:CommandParse')">Instances</p><div id="section.i:CommandParse" class="show"><table><tr><td class="src"><a href="../base-4.5.1.0/Control-Monad.html#t:Functor">Functor</a> <a href="Distribution-Simple-Command.html#t:CommandParse">CommandParse</a></td><td class="doc empty"> </td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:commandParseArgs" class="def">commandParseArgs</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Distribution-Simple-Command.html#t:CommandUI">CommandUI</a> flags</td><td class="doc empty"> </td></tr><tr><td class="src">-> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></td><td class="doc"><p>Is the command a global or subcommand? </p></td></tr><tr><td class="src">-> [<a href="../base-4.5.1.0/Data-String.html#t:String">String</a>]</td><td class="doc empty"> </td></tr><tr><td class="src">-> <a href="Distribution-Simple-Command.html#t:CommandParse">CommandParse</a> (flags -> flags, [<a href="../base-4.5.1.0/Data-String.html#t:String">String</a>])</td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Parse a bunch of command line arguments </p></div></div><h2 id="g:2">Constructing commands </h2><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:ShowOrParseArgs" class="def">ShowOrParseArgs</a> </p><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:ShowArgs" class="def">ShowArgs</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a name="v:ParseArgs" class="def">ParseArgs</a></td><td class="doc empty"> </td></tr></table></div></div><div class="top"><p class="src"><a name="v:makeCommand" class="def">makeCommand</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="../base-4.5.1.0/Data-String.html#t:String">String</a></td><td class="doc"><p>name </p></td></tr><tr><td class="src">-> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a></td><td class="doc"><p>short description </p></td></tr><tr><td class="src">-> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> (<a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a>)</td><td class="doc"><p>long description </p></td></tr><tr><td class="src">-> flags</td><td class="doc"><p>initial/empty flags </p></td></tr><tr><td class="src">-> (<a href="Distribution-Simple-Command.html#t:ShowOrParseArgs">ShowOrParseArgs</a> -> [<a href="Distribution-Simple-Command.html#t:OptionField">OptionField</a> flags])</td><td class="doc"><p>options </p></td></tr><tr><td class="src">-> <a href="Distribution-Simple-Command.html#t:CommandUI">CommandUI</a> flags</td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Make a Command from standard <code>GetOpt</code> options. </p></div></div><h2 id="g:3">Associating actions with commands </h2><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:Command" class="def">Command</a> action </p></div><div class="top"><p class="src"><a name="v:commandAddAction" class="def">commandAddAction</a> :: <a href="Distribution-Simple-Command.html#t:CommandUI">CommandUI</a> flags -> (flags -> [<a href="../base-4.5.1.0/Data-String.html#t:String">String</a>] -> action) -> <a href="Distribution-Simple-Command.html#t:Command">Command</a> action</p></div><div class="top"><p class="src"><a name="v:noExtraFlags" class="def">noExtraFlags</a> :: [<a href="../base-4.5.1.0/Data-String.html#t:String">String</a>] -> <a href="../base-4.5.1.0/System-IO.html#t:IO">IO</a> ()</p><div class="doc"><p>Utility function, many commands do not accept additional flags. This action fails with a helpful error message if the user supplies any extra. </p></div></div><h2 id="g:4">Running commands </h2><div class="top"><p class="src"><a name="v:commandsRun" class="def">commandsRun</a> :: <a href="Distribution-Simple-Command.html#t:CommandUI">CommandUI</a> a -> [<a href="Distribution-Simple-Command.html#t:Command">Command</a> action] -> [<a href="../base-4.5.1.0/Data-String.html#t:String">String</a>] -> <a href="Distribution-Simple-Command.html#t:CommandParse">CommandParse</a> (a, <a href="Distribution-Simple-Command.html#t:CommandParse">CommandParse</a> action)</p></div><h1 id="g:5">Option Fields </h1><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:OptionField" class="def">OptionField</a> a </p><div class="doc"><p>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. </p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:OptionField" class="def">OptionField</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div class="subs fields"><p class="caption">Fields</p><dl><dt class="src"><a name="v:optionName" class="def">optionName</a> :: <a href="Distribution-Simple-Command.html#t:Name">Name</a></dt><dd class="doc empty"> </dd><dt class="src"><a name="v:optionDescr" class="def">optionDescr</a> :: [<a href="Distribution-Simple-Command.html#t:OptDescr">OptDescr</a> a]</dt><dd class="doc empty"> </dd></dl><div class="clear"></div></div></td></tr></table></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:Name" class="def">Name</a> = <a href="../base-4.5.1.0/Data-String.html#t:String">String</a></p></div><h2 id="g:6">Constructing Option Fields </h2><div class="top"><p class="src"><a name="v:option" class="def">option</a> :: <a href="Distribution-Simple-Command.html#t:SFlags">SFlags</a> -> <a href="Distribution-Simple-Command.html#t:LFlags">LFlags</a> -> <a href="Distribution-Simple-Command.html#t:Description">Description</a> -> get -> set -> <a href="Distribution-Simple-Command.html#t:MkOptDescr">MkOptDescr</a> get set a -> <a href="Distribution-Simple-Command.html#t:OptionField">OptionField</a> a</p><div class="doc"><p>Create an option taking a single OptDescr. No explicit Name is given for the Option, the name is the first LFlag given. </p></div></div><div class="top"><p class="src"><a name="v:multiOption" class="def">multiOption</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Distribution-Simple-Command.html#t:Name">Name</a></td><td class="doc empty"> </td></tr><tr><td class="src">-> get</td><td class="doc empty"> </td></tr><tr><td class="src">-> set</td><td class="doc empty"> </td></tr><tr><td class="src">-> [get -> set -> <a href="Distribution-Simple-Command.html#t:OptDescr">OptDescr</a> a]</td><td class="doc"><p>MkOptDescr constructors partially applied to flags and description. </p></td></tr><tr><td class="src">-> <a href="Distribution-Simple-Command.html#t:OptionField">OptionField</a> a</td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Create an option taking several OptDescrs. You will have to give the flags and description individually to the OptDescr constructor. </p></div></div><h2 id="g:7">Liftings & Projections </h2><div class="top"><p class="src"><a name="v:liftOption" class="def">liftOption</a> :: (b -> a) -> (a -> b -> b) -> <a href="Distribution-Simple-Command.html#t:OptionField">OptionField</a> a -> <a href="Distribution-Simple-Command.html#t:OptionField">OptionField</a> b</p></div><div class="top"><p class="src"><a name="v:viewAsFieldDescr" class="def">viewAsFieldDescr</a> :: <a href="Distribution-Simple-Command.html#t:OptionField">OptionField</a> a -> <a href="Distribution-ParseUtils.html#t:FieldDescr">FieldDescr</a> a</p><div class="doc"><p>to view as a FieldDescr, we sort the list of interfaces (Req > Bool > Choice > Opt) and consider only the first one. </p></div></div><h1 id="g:8">Option Descriptions </h1><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:OptDescr" class="def">OptDescr</a> a </p><div class="doc"><p>An OptionField takes one or more OptDescrs, describing the command line interface for the field. </p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:ReqArg" class="def">ReqArg</a> <a href="Distribution-Simple-Command.html#t:Description">Description</a> <a href="Distribution-Simple-Command.html#t:OptFlags">OptFlags</a> <a href="Distribution-Simple-Command.html#t:ArgPlaceHolder">ArgPlaceHolder</a> (<a href="Distribution-ReadE.html#t:ReadE">ReadE</a> (a -> a)) (a -> [<a href="../base-4.5.1.0/Data-String.html#t:String">String</a>])</td><td class="doc empty"> </td></tr><tr><td class="src"><a name="v:OptArg" class="def">OptArg</a> <a href="Distribution-Simple-Command.html#t:Description">Description</a> <a href="Distribution-Simple-Command.html#t:OptFlags">OptFlags</a> <a href="Distribution-Simple-Command.html#t:ArgPlaceHolder">ArgPlaceHolder</a> (<a href="Distribution-ReadE.html#t:ReadE">ReadE</a> (a -> a)) (a -> a) (a -> [<a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a>])</td><td class="doc empty"> </td></tr><tr><td class="src"><a name="v:ChoiceOpt" class="def">ChoiceOpt</a> [(<a href="Distribution-Simple-Command.html#t:Description">Description</a>, <a href="Distribution-Simple-Command.html#t:OptFlags">OptFlags</a>, a -> a, a -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>)]</td><td class="doc empty"> </td></tr><tr><td class="src"><a name="v:BoolOpt" class="def">BoolOpt</a> <a href="Distribution-Simple-Command.html#t:Description">Description</a> <a href="Distribution-Simple-Command.html#t:OptFlags">OptFlags</a> <a href="Distribution-Simple-Command.html#t:OptFlags">OptFlags</a> (<a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a> -> a -> a) (a -> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>)</td><td class="doc empty"> </td></tr></table></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:Description" class="def">Description</a> = <a href="../base-4.5.1.0/Data-String.html#t:String">String</a></p></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:SFlags" class="def">SFlags</a> = [<a href="../base-4.5.1.0/Data-Char.html#t:Char">Char</a>]</p><div class="doc"><p>Short command line option strings </p></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:LFlags" class="def">LFlags</a> = [<a href="../base-4.5.1.0/Data-String.html#t:String">String</a>]</p><div class="doc"><p>Long command line option strings </p></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:OptFlags" class="def">OptFlags</a> = (<a href="Distribution-Simple-Command.html#t:SFlags">SFlags</a>, <a href="Distribution-Simple-Command.html#t:LFlags">LFlags</a>)</p></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:ArgPlaceHolder" class="def">ArgPlaceHolder</a> = <a href="../base-4.5.1.0/Data-String.html#t:String">String</a></p></div><h2 id="g:9">OptDescr <code>smart</code> constructors </h2><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:MkOptDescr" class="def">MkOptDescr</a> get set a = <a href="Distribution-Simple-Command.html#t:SFlags">SFlags</a> -> <a href="Distribution-Simple-Command.html#t:LFlags">LFlags</a> -> <a href="Distribution-Simple-Command.html#t:Description">Description</a> -> get -> set -> <a href="Distribution-Simple-Command.html#t:OptDescr">OptDescr</a> a</p></div><div class="top"><p class="src"><a name="v:reqArg" class="def">reqArg</a> :: <a href="../base-4.5.1.0/Data-Monoid.html#t:Monoid">Monoid</a> b => <a href="Distribution-Simple-Command.html#t:ArgPlaceHolder">ArgPlaceHolder</a> -> <a href="Distribution-ReadE.html#t:ReadE">ReadE</a> b -> (b -> [<a href="../base-4.5.1.0/Data-String.html#t:String">String</a>]) -> <a href="Distribution-Simple-Command.html#t:MkOptDescr">MkOptDescr</a> (a -> b) (b -> a -> a) a</p><div class="doc"><p>Create a string-valued command line interface. </p></div></div><div class="top"><p class="src"><a name="v:reqArg-39-" class="def">reqArg'</a> :: <a href="../base-4.5.1.0/Data-Monoid.html#t:Monoid">Monoid</a> b => <a href="Distribution-Simple-Command.html#t:ArgPlaceHolder">ArgPlaceHolder</a> -> (<a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> b) -> (b -> [<a href="../base-4.5.1.0/Data-String.html#t:String">String</a>]) -> <a href="Distribution-Simple-Command.html#t:MkOptDescr">MkOptDescr</a> (a -> b) (b -> a -> a) a</p><div class="doc"><p>(String -> a) variant of <a href="reqArg.html">reqArg</a> </p></div></div><div class="top"><p class="src"><a name="v:optArg" class="def">optArg</a> :: <a href="../base-4.5.1.0/Data-Monoid.html#t:Monoid">Monoid</a> b => <a href="Distribution-Simple-Command.html#t:ArgPlaceHolder">ArgPlaceHolder</a> -> <a href="Distribution-ReadE.html#t:ReadE">ReadE</a> b -> b -> (b -> [<a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a>]) -> <a href="Distribution-Simple-Command.html#t:MkOptDescr">MkOptDescr</a> (a -> b) (b -> a -> a) a</p><div class="doc"><p>Create a string-valued command line interface with a default value. </p></div></div><div class="top"><p class="src"><a name="v:optArg-39-" class="def">optArg'</a> :: <a href="../base-4.5.1.0/Data-Monoid.html#t:Monoid">Monoid</a> b => <a href="Distribution-Simple-Command.html#t:ArgPlaceHolder">ArgPlaceHolder</a> -> (<a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> b) -> (b -> [<a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a>]) -> <a href="Distribution-Simple-Command.html#t:MkOptDescr">MkOptDescr</a> (a -> b) (b -> a -> a) a</p><div class="doc"><p>(String -> a) variant of <a href="optArg.html">optArg</a> </p></div></div><div class="top"><p class="src"><a name="v:noArg" class="def">noArg</a> :: (<a href="../base-4.5.1.0/Data-Eq.html#t:Eq">Eq</a> b, <a href="../base-4.5.1.0/Data-Monoid.html#t:Monoid">Monoid</a> b) => b -> <a href="Distribution-Simple-Command.html#t:MkOptDescr">MkOptDescr</a> (a -> b) (b -> a -> a) a</p></div><div class="top"><p class="src"><a name="v:boolOpt" class="def">boolOpt</a> :: (b -> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>) -> (<a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a> -> b) -> <a href="Distribution-Simple-Command.html#t:SFlags">SFlags</a> -> <a href="Distribution-Simple-Command.html#t:SFlags">SFlags</a> -> <a href="Distribution-Simple-Command.html#t:MkOptDescr">MkOptDescr</a> (a -> b) (b -> a -> a) a</p></div><div class="top"><p class="src"><a name="v:boolOpt-39-" class="def">boolOpt'</a> :: (b -> <a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a>) -> (<a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a> -> b) -> <a href="Distribution-Simple-Command.html#t:OptFlags">OptFlags</a> -> <a href="Distribution-Simple-Command.html#t:OptFlags">OptFlags</a> -> <a href="Distribution-Simple-Command.html#t:MkOptDescr">MkOptDescr</a> (a -> b) (b -> a -> a) a</p></div><div class="top"><p class="src"><a name="v:choiceOpt" class="def">choiceOpt</a> :: <a href="../base-4.5.1.0/Data-Eq.html#t:Eq">Eq</a> b => [(b, <a href="Distribution-Simple-Command.html#t:OptFlags">OptFlags</a>, <a href="Distribution-Simple-Command.html#t:Description">Description</a>)] -> <a href="Distribution-Simple-Command.html#t:MkOptDescr">MkOptDescr</a> (a -> b) (b -> a -> a) a</p><div class="doc"><p>create a Choice option </p></div></div><div class="top"><p class="src"><a name="v:choiceOptFromEnum" class="def">choiceOptFromEnum</a> :: (<a href="../base-4.5.1.0/Prelude.html#t:Bounded">Bounded</a> b, <a href="../base-4.5.1.0/Prelude.html#t:Enum">Enum</a> b, <a href="../base-4.5.1.0/Text-Show.html#t:Show">Show</a> b, <a href="../base-4.5.1.0/Data-Eq.html#t:Eq">Eq</a> b) => <a href="Distribution-Simple-Command.html#t:MkOptDescr">MkOptDescr</a> (a -> b) (b -> a -> a) a</p><div class="doc"><p>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. </p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.11.0</p></div></body></html>