Sophie

Sophie

distrib > Fedora > 17 > i386 > media > updates > by-pkgid > a754cb499dfee5e1f453d3b6cc13d4c8 > files > 89

ghc-cmdargs-devel-0.9.3-1.fc17.i686.rpm

<!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>System.Console.CmdArgs.Explicit</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_System-Console-CmdArgs-Explicit.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/System-Console-CmdArgs-Explicit.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">cmdargs-0.9.3: Command line argument processing</p></div><div id="content"><div id="module-header"><p class="caption">System.Console.CmdArgs.Explicit</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Running command lines
</a></li><li><a href="#g:2">Constructing command lines
</a></li><li><a href="#g:3">Displaying help
</a></li><li><a href="#g:4">Utilities for working with command lines
</a></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>This module constructs command lines. You may either use the helper functions
    (<code><a href="System-Console-CmdArgs-Explicit.html#v:flagNone">flagNone</a></code>, <code><a href="System-Console-CmdArgs-Explicit.html#v:flagOpt">flagOpt</a></code>, <code><a href="System-Console-CmdArgs-Explicit.html#v:mode">mode</a></code> etc.) or construct the type directly. These
    types are intended to give all the necessary power to the person constructing
    a command line parser.
</p><p>For people constructing simpler command line parsers, the module
    <a href="System-Console-CmdArgs-Implicit.html">System.Console.CmdArgs.Implicit</a> may be more appropriate.
</p><p>As an example of a parser:
</p><pre>
    arguments :: <code><a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a></code> [(String,String)]
    arguments = <code><a href="System-Console-CmdArgs-Explicit.html#v:mode">mode</a></code> &quot;explicit&quot; [] &quot;Explicit sample program&quot; (<code><a href="System-Console-CmdArgs-Explicit.html#v:flagArg">flagArg</a></code> (upd &quot;file&quot;) &quot;FILE&quot;)
        [<code><a href="System-Console-CmdArgs-Explicit.html#v:flagOpt">flagOpt</a></code> &quot;world&quot; [&quot;hello&quot;,&quot;h&quot;] (upd &quot;world&quot;) &quot;WHO&quot; &quot;World argument&quot;
        ,<code><a href="System-Console-CmdArgs-Explicit.html#v:flagReq">flagReq</a></code> [&quot;greeting&quot;,&quot;g&quot;] (upd &quot;greeting&quot;) &quot;MSG&quot; &quot;Greeting to give&quot;
        ,<code><a href="System-Console-CmdArgs-Explicit.html#v:flagHelpSimple">flagHelpSimple</a></code> ((&quot;help&quot;,&quot;&quot;):)]
        where upd msg x v = Right $ (msg,x):v
</pre><p>And this can be invoked by:
</p><pre>
    main = do
        xs &lt;- <code><a href="System-Console-CmdArgs-Explicit.html#v:processArgs">processArgs</a></code> arguments
        if (&quot;help&quot;,&quot;&quot;) `elem` xs then
            print $ <code><a href="System-Console-CmdArgs-Explicit.html#v:helpText">helpText</a></code> [] <code><a href="System-Console-CmdArgs-Explicit.html#v:HelpFormatDefault">HelpFormatDefault</a></code> arguments
         else
            print xs
</pre><p><em>Groups</em>: The <code><a href="System-Console-CmdArgs-Explicit.html#t:Group">Group</a></code> structure allows flags/modes to be grouped for the purpose of
    displaying help. When processing command lines, the group structure is ignored.
</p><p><em>Modes</em>: The Explicit module allows multiple mode programs by placing additional modes
    in <code><a href="System-Console-CmdArgs-Explicit.html#v:modeGroupModes">modeGroupModes</a></code>. Every mode is allowed sub-modes, and thus multiple levels of mode
    may be created. Given a mode <code>x</code> with sub-modes <code>xs</code>, if the first argument corresponds
    to the name of a sub-mode, then that sub-mode will be applied. If not, then the arguments
    will be processed by mode <code>x</code>. Consequently, if you wish to force the user to explicitly
    enter a mode, simply give sub-modes, and leave <code><a href="System-Console-CmdArgs-Explicit.html#v:modeArgs">modeArgs</a></code> as <code>Nothing</code>. Alternatively, if
    you want one sub-mode to be selected by default, place all it's flags both in the sub-mode
    and the outer mode.
</p><p><em>Parsing rules</em>: Command lines are parsed as per most GNU programs. Short arguments single
    letter flags start with <code>-</code>, longer flags start with <code>--</code>, and everything else is considered
    an argument. Anything after <code>--</code> alone is considered to be an argument. For example:
</p><pre> -f --flag argument1 -- --argument2
</pre><p>This command line passes one single letter flag (<code>f</code>), one longer flag (<code>flag</code>) and two arguments
    (<code>argument1</code> and <code>--argument2</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"><a href="#v:process">process</a> ::  <a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a> a -&gt; [<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a>] -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Either.html#t:Either">Either</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> a</li><li class="src short"><a href="#v:processArgs">processArgs</a> ::  <a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a> a -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> a</li><li class="src short"><a href="#v:processValue">processValue</a> ::  <a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a> a -&gt; [<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a>] -&gt; a</li><li class="src short"><span class="keyword">type</span> <a href="#t:Name">Name</a> = <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a></li><li class="src short"><span class="keyword">type</span> <a href="#t:Help">Help</a> = <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a></li><li class="src short"><span class="keyword">type</span> <a href="#t:FlagHelp">FlagHelp</a> = <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a></li><li class="src short"><a href="#v:parseBool">parseBool</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><span class="keyword">data</span>  <a href="#t:Group">Group</a> a = <a href="#v:Group">Group</a> {<ul class="subs"><li><a href="#v:groupUnnamed">groupUnnamed</a> :: [a]</li><li><a href="#v:groupHidden">groupHidden</a> :: [a]</li><li><a href="#v:groupNamed">groupNamed</a> :: [(<a href="System-Console-CmdArgs-Explicit.html#t:Help">Help</a>, [a])]</li></ul>}</li><li class="src short"><a href="#v:fromGroup">fromGroup</a> ::  <a href="System-Console-CmdArgs-Explicit.html#t:Group">Group</a> a -&gt; [a]</li><li class="src short"><a href="#v:toGroup">toGroup</a> ::  [a] -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Group">Group</a> a</li><li class="src short"><span class="keyword">data</span>  <a href="#t:Mode">Mode</a> a = <a href="#v:Mode">Mode</a> {<ul class="subs"><li><a href="#v:modeGroupModes">modeGroupModes</a> :: <a href="System-Console-CmdArgs-Explicit.html#t:Group">Group</a> (<a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a> a)</li><li><a href="#v:modeNames">modeNames</a> :: [<a href="System-Console-CmdArgs-Explicit.html#t:Name">Name</a>]</li><li><a href="#v:modeValue">modeValue</a> :: a</li><li><a href="#v:modeCheck">modeCheck</a> :: a -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Either.html#t:Either">Either</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> a</li><li><a href="#v:modeReform">modeReform</a> :: a -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Maybe.html#t:Maybe">Maybe</a> [<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a>]</li><li><a href="#v:modeHelp">modeHelp</a> :: <a href="System-Console-CmdArgs-Explicit.html#t:Help">Help</a></li><li><a href="#v:modeHelpSuffix">modeHelpSuffix</a> :: [<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a>]</li><li><a href="#v:modeArgs">modeArgs</a> :: ([<a href="System-Console-CmdArgs-Explicit.html#t:Arg">Arg</a> a], <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Maybe.html#t:Maybe">Maybe</a> (<a href="System-Console-CmdArgs-Explicit.html#t:Arg">Arg</a> a))</li><li><a href="#v:modeGroupFlags">modeGroupFlags</a> :: <a href="System-Console-CmdArgs-Explicit.html#t:Group">Group</a> (<a href="System-Console-CmdArgs-Explicit.html#t:Flag">Flag</a> a)</li></ul>}</li><li class="src short"><a href="#v:modeModes">modeModes</a> ::  <a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a> a -&gt; [<a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a> a]</li><li class="src short"><a href="#v:modeFlags">modeFlags</a> ::  <a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a> a -&gt; [<a href="System-Console-CmdArgs-Explicit.html#t:Flag">Flag</a> a]</li><li class="src short"><span class="keyword">data</span>  <a href="#t:FlagInfo">FlagInfo</a> <ul class="subs"><li>= <a href="#v:FlagReq">FlagReq</a>  </li><li>| <a href="#v:FlagOpt">FlagOpt</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a>  </li><li>| <a href="#v:FlagOptRare">FlagOptRare</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a>  </li><li>| <a href="#v:FlagNone">FlagNone</a>  </li></ul></li><li class="src short"><a href="#v:fromFlagOpt">fromFlagOpt</a> :: <a href="System-Console-CmdArgs-Explicit.html#t:FlagInfo">FlagInfo</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a></li><li class="src short"><span class="keyword">type</span> <a href="#t:Update">Update</a> a = <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> -&gt; a -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Either.html#t:Either">Either</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> a</li><li class="src short"><span class="keyword">data</span>  <a href="#t:Flag">Flag</a> a = <a href="#v:Flag">Flag</a> {<ul class="subs"><li><a href="#v:flagNames">flagNames</a> :: [<a href="System-Console-CmdArgs-Explicit.html#t:Name">Name</a>]</li><li><a href="#v:flagInfo">flagInfo</a> :: <a href="System-Console-CmdArgs-Explicit.html#t:FlagInfo">FlagInfo</a></li><li><a href="#v:flagValue">flagValue</a> :: <a href="System-Console-CmdArgs-Explicit.html#t:Update">Update</a> a</li><li><a href="#v:flagType">flagType</a> :: <a href="System-Console-CmdArgs-Explicit.html#t:FlagHelp">FlagHelp</a></li><li><a href="#v:flagHelp">flagHelp</a> :: <a href="System-Console-CmdArgs-Explicit.html#t:Help">Help</a></li></ul>}</li><li class="src short"><span class="keyword">data</span>  <a href="#t:Arg">Arg</a> a = <a href="#v:Arg">Arg</a> {<ul class="subs"><li><a href="#v:argValue">argValue</a> :: <a href="System-Console-CmdArgs-Explicit.html#t:Update">Update</a> a</li><li><a href="#v:argType">argType</a> :: <a href="System-Console-CmdArgs-Explicit.html#t:FlagHelp">FlagHelp</a></li><li><a href="#v:argRequire">argRequire</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Bool.html#t:Bool">Bool</a></li></ul>}</li><li class="src short"><a href="#v:checkMode">checkMode</a> ::  <a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a> a -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a></li><li class="src short"><span class="keyword">class</span>  <a href="#t:Remap">Remap</a> m  <span class="keyword">where</span><ul class="subs"><li><a href="#v:remap">remap</a> ::  (a -&gt; b) -&gt; (b -&gt; (a, a -&gt; b)) -&gt; m a -&gt; m b</li></ul></li><li class="src short"><a href="#v:remap2">remap2</a> :: <a href="System-Console-CmdArgs-Explicit.html#t:Remap">Remap</a> m =&gt; (a -&gt; b) -&gt; (b -&gt; a) -&gt; m a -&gt; m b</li><li class="src short"><a href="#v:modeEmpty">modeEmpty</a> ::  a -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a> a</li><li class="src short"><a href="#v:mode">mode</a> ::  <a href="System-Console-CmdArgs-Explicit.html#t:Name">Name</a> -&gt; a -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Help">Help</a> -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Arg">Arg</a> a -&gt; [<a href="System-Console-CmdArgs-Explicit.html#t:Flag">Flag</a> a] -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a> a</li><li class="src short"><a href="#v:modes">modes</a> ::  <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> -&gt; a -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Help">Help</a> -&gt; [<a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a> a] -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a> a</li><li class="src short"><a href="#v:flagNone">flagNone</a> ::  [<a href="System-Console-CmdArgs-Explicit.html#t:Name">Name</a>] -&gt; (a -&gt; a) -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Help">Help</a> -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Flag">Flag</a> a</li><li class="src short"><a href="#v:flagOpt">flagOpt</a> ::  <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> -&gt; [<a href="System-Console-CmdArgs-Explicit.html#t:Name">Name</a>] -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Update">Update</a> a -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:FlagHelp">FlagHelp</a> -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Help">Help</a> -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Flag">Flag</a> a</li><li class="src short"><a href="#v:flagReq">flagReq</a> ::  [<a href="System-Console-CmdArgs-Explicit.html#t:Name">Name</a>] -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Update">Update</a> a -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:FlagHelp">FlagHelp</a> -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Help">Help</a> -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Flag">Flag</a> a</li><li class="src short"><a href="#v:flagArg">flagArg</a> ::  <a href="System-Console-CmdArgs-Explicit.html#t:Update">Update</a> a -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:FlagHelp">FlagHelp</a> -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Arg">Arg</a> a</li><li class="src short"><a href="#v:flagBool">flagBool</a> ::  [<a href="System-Console-CmdArgs-Explicit.html#t:Name">Name</a>] -&gt; (<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Bool.html#t:Bool">Bool</a> -&gt; a -&gt; a) -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Help">Help</a> -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Flag">Flag</a> a</li><li class="src short"><a href="#v:flagHelpSimple">flagHelpSimple</a> ::  (a -&gt; a) -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Flag">Flag</a> a</li><li class="src short"><a href="#v:flagHelpFormat">flagHelpFormat</a> ::  (<a href="System-Console-CmdArgs-Explicit.html#t:HelpFormat">HelpFormat</a> -&gt; <a href="System-Console-CmdArgs-Text.html#t:TextFormat">TextFormat</a> -&gt; a -&gt; a) -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Flag">Flag</a> a</li><li class="src short"><a href="#v:flagVersion">flagVersion</a> ::  (a -&gt; a) -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Flag">Flag</a> a</li><li class="src short"><a href="#v:flagsVerbosity">flagsVerbosity</a> ::  (<a href="System-Console-CmdArgs-Verbosity.html#t:Verbosity">Verbosity</a> -&gt; a -&gt; a) -&gt; [<a href="System-Console-CmdArgs-Explicit.html#t:Flag">Flag</a> a]</li><li class="src short"><span class="keyword">data</span>  <a href="#t:HelpFormat">HelpFormat</a> <ul class="subs"><li>= <a href="#v:HelpFormatDefault">HelpFormatDefault</a>  </li><li>| <a href="#v:HelpFormatOne">HelpFormatOne</a>  </li><li>| <a href="#v:HelpFormatAll">HelpFormatAll</a>  </li><li>| <a href="#v:HelpFormatBash">HelpFormatBash</a>  </li><li>| <a href="#v:HelpFormatZsh">HelpFormatZsh</a>  </li></ul></li><li class="src short"><a href="#v:helpText">helpText</a> ::  [<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a>] -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:HelpFormat">HelpFormat</a> -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a> a -&gt; [<a href="System-Console-CmdArgs-Text.html#t:Text">Text</a>]</li><li class="src short"><a href="#v:expandArgsAt">expandArgsAt</a> :: [<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a>] -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> [<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a>]</li><li class="src short"><a href="#v:splitArgs">splitArgs</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> -&gt; [<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a>]</li><li class="src short"><a href="#v:joinArgs">joinArgs</a> :: [<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a>] -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a></li><li class="src short"><span class="keyword">data</span>  <a href="#t:Complete">Complete</a> <ul class="subs"><li>= <a href="#v:CompleteValue">CompleteValue</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a>  </li><li>| <a href="#v:CompleteFile">CompleteFile</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:FilePath">FilePath</a>  </li><li>| <a href="#v:CompleteDir">CompleteDir</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:FilePath">FilePath</a>  </li></ul></li><li class="src short"><a href="#v:complete">complete</a> ::  <a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a> a -&gt; [<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a>] -&gt; (<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a>, <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a>) -&gt; [<a href="System-Console-CmdArgs-Explicit.html#t:Complete">Complete</a>]</li></ul></div><div id="interface"><h1 id="g:1">Running command lines
</h1><div class="top"><p class="src"><a name="v:process" class="def">process</a> ::  <a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a> a -&gt; [<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a>] -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Either.html#t:Either">Either</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> a<a href="src/System-Console-CmdArgs-Explicit-Process.html#process" class="link">Source</a></p><div class="doc"><p>Process a list of flags (usually obtained from <code>getArgs</code>/<code>expandArgsAt</code>) with a mode. Returns
   <code>Left</code> and an error message if the command line fails to parse, or <code>Right</code> and
   the associated value.
</p></div></div><div class="top"><p class="src"><a name="v:processArgs" class="def">processArgs</a> ::  <a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a> a -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> a<a href="src/System-Console-CmdArgs-Explicit.html#processArgs" class="link">Source</a></p><div class="doc"><p>Process the flags obtained by <code><code><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-Environment.html#v:getArgs">getArgs</a></code></code> and <code><code><a href="System-Console-CmdArgs-Explicit.html#v:expandArgsAt">expandArgsAt</a></code></code> with a mode. Displays
   an error and exits with failure if the command line fails to parse, or returns
   the associated value. Implemented in terms of <code><a href="System-Console-CmdArgs-Explicit.html#v:process">process</a></code>. This function makes
   use of the following environment variables:
</p><ul><li> <code>$CMDARGS_COMPLETE</code> - causes the program to produce completions using <code><a href="System-Console-CmdArgs-Explicit.html#v:complete">complete</a></code>, then exit.
   Completions are based on the result of <code><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-Environment.html#v:getArgs">getArgs</a></code>, the index of the current argument is taken
   from <code>$CMDARGS_COMPLETE</code> (set it to <code>-</code> to complete the last argument), and the index within
   that argument is taken from <code>$CMDARGS_COMPLETE_POS</code> (if set).
</li><li> <code>$CMDARGS_HELPER</code>/<code>$CMDARGS_HELPER_<em>PROG</em></code> - uses the helper mechanism for entering command
   line programs as described in <a href="System-Console-CmdArgs-Helper.html">System.Console.CmdArgs.Helper</a>.
</li></ul></div></div><div class="top"><p class="src"><a name="v:processValue" class="def">processValue</a> ::  <a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a> a -&gt; [<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a>] -&gt; a<a href="src/System-Console-CmdArgs-Explicit.html#processValue" class="link">Source</a></p><div class="doc"><p>Process a list of flags (usually obtained from <code><code><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-Environment.html#v:getArgs">getArgs</a></code></code> and <code><code><a href="System-Console-CmdArgs-Explicit.html#v:expandArgsAt">expandArgsAt</a></code></code>) with a mode. Displays
   an error and exits with failure if the command line fails to parse, or returns
   the associated value. Implemeneted in terms of <code><a href="System-Console-CmdArgs-Explicit.html#v:process">process</a></code>. This function
   does not take account of any environment variables that may be set
   (see <code><a href="System-Console-CmdArgs-Explicit.html#v:processArgs">processArgs</a></code>).
</p></div></div><h1 id="g:2">Constructing command lines
</h1><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:Name" class="def">Name</a> = <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a><a href="src/System-Console-CmdArgs-Explicit-Type.html#Name" class="link">Source</a></p><div class="doc"><p>A name, either the name of a flag (<code>--<em>foo</em></code>) or the name of a mode.
</p></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:Help" class="def">Help</a> = <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a><a href="src/System-Console-CmdArgs-Explicit-Type.html#Help" class="link">Source</a></p><div class="doc"><p>A help message that goes with either a flag or a mode.
</p></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:FlagHelp" class="def">FlagHelp</a> = <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a><a href="src/System-Console-CmdArgs-Explicit-Type.html#FlagHelp" class="link">Source</a></p><div class="doc"><p>The type of a flag, i.e. <code>--foo=<em>TYPE</em></code>.
</p></div></div><div class="top"><p class="src"><a name="v:parseBool" class="def">parseBool</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Bool.html#t:Bool">Bool</a><a href="src/System-Console-CmdArgs-Explicit-Type.html#parseBool" class="link">Source</a></p><div class="doc"><p>Parse a boolean, accepts as True: true yes on enabled 1. 
</p></div></div><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:Group" class="def">Group</a> a <a href="src/System-Console-CmdArgs-Explicit-Type.html#Group" class="link">Source</a></p><div class="doc"><p>A group of items (modes or flags). The items are treated as a list, but the
   group structure is used when displaying the help message.
</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:Group" class="def">Group</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div class="subs fields"><p class="caption">Fields</p><dl><dt class="src"><a name="v:groupUnnamed" class="def">groupUnnamed</a> :: [a]</dt><dd class="doc"><p>Normal items.
</p></dd><dt class="src"><a name="v:groupHidden" class="def">groupHidden</a> :: [a]</dt><dd class="doc"><p>Items that are hidden (not displayed in the help message).
</p></dd><dt class="src"><a name="v:groupNamed" class="def">groupNamed</a> :: [(<a href="System-Console-CmdArgs-Explicit.html#t:Help">Help</a>, [a])]</dt><dd class="doc"><p>Items that have been grouped, along with a description of each group.
</p></dd></dl><div class="clear"></div></div></td></tr></table></div><div class="subs instances"><p id="control.i:Group" class="caption collapser" onclick="toggleSection('i:Group')">Instances</p><div id="section.i:Group" class="show"><table><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Control-Monad.html#t:Functor">Functor</a> <a href="System-Console-CmdArgs-Explicit.html#t:Group">Group</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Text-Show.html#t:Show">Show</a> a =&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Text-Show.html#t:Show">Show</a> (<a href="System-Console-CmdArgs-Explicit.html#t:Group">Group</a> a)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Monoid.html#t:Monoid">Monoid</a> (<a href="System-Console-CmdArgs-Explicit.html#t:Group">Group</a> a)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">Packer a =&gt; Packer (<a href="System-Console-CmdArgs-Explicit.html#t:Group">Group</a> a)</td><td class="doc empty">&nbsp;</td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:fromGroup" class="def">fromGroup</a> ::  <a href="System-Console-CmdArgs-Explicit.html#t:Group">Group</a> a -&gt; [a]<a href="src/System-Console-CmdArgs-Explicit-Type.html#fromGroup" class="link">Source</a></p><div class="doc"><p>Convert a group into a list.
</p></div></div><div class="top"><p class="src"><a name="v:toGroup" class="def">toGroup</a> ::  [a] -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Group">Group</a> a<a href="src/System-Console-CmdArgs-Explicit-Type.html#toGroup" class="link">Source</a></p><div class="doc"><p>Convert a list into a group, placing all fields in <code><a href="System-Console-CmdArgs-Explicit.html#v:groupUnnamed">groupUnnamed</a></code>.
</p></div></div><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:Mode" class="def">Mode</a> a <a href="src/System-Console-CmdArgs-Explicit-Type.html#Mode" class="link">Source</a></p><div class="doc"><p>A mode. Each mode has three main features:
</p><ul><li> A list of submodes (<code><a href="System-Console-CmdArgs-Explicit.html#v:modeGroupModes">modeGroupModes</a></code>)
</li><li> A list of flags (<code><a href="System-Console-CmdArgs-Explicit.html#v:modeGroupFlags">modeGroupFlags</a></code>)
</li><li> Optionally an unnamed argument (<code><a href="System-Console-CmdArgs-Explicit.html#v:modeArgs">modeArgs</a></code>)
</li></ul></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:Mode" class="def">Mode</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div class="subs fields"><p class="caption">Fields</p><dl><dt class="src"><a name="v:modeGroupModes" class="def">modeGroupModes</a> :: <a href="System-Console-CmdArgs-Explicit.html#t:Group">Group</a> (<a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a> a)</dt><dd class="doc"><p>The available sub-modes
</p></dd><dt class="src"><a name="v:modeNames" class="def">modeNames</a> :: [<a href="System-Console-CmdArgs-Explicit.html#t:Name">Name</a>]</dt><dd class="doc"><p>The names assigned to this mode (for the root mode, this name is used as the program name)
</p></dd><dt class="src"><a name="v:modeValue" class="def">modeValue</a> :: a</dt><dd class="doc"><p>Value to start with
</p></dd><dt class="src"><a name="v:modeCheck" class="def">modeCheck</a> :: a -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Either.html#t:Either">Either</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> a</dt><dd class="doc"><p>Check the value reprsented by a mode is correct, after applying all flags
</p></dd><dt class="src"><a name="v:modeReform" class="def">modeReform</a> :: a -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Maybe.html#t:Maybe">Maybe</a> [<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a>]</dt><dd class="doc"><p>Given a value, try to generate the input arguments.
</p></dd><dt class="src"><a name="v:modeHelp" class="def">modeHelp</a> :: <a href="System-Console-CmdArgs-Explicit.html#t:Help">Help</a></dt><dd class="doc"><p>Help text
</p></dd><dt class="src"><a name="v:modeHelpSuffix" class="def">modeHelpSuffix</a> :: [<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a>]</dt><dd class="doc"><p>A longer help suffix displayed after a mode
</p></dd><dt class="src"><a name="v:modeArgs" class="def">modeArgs</a> :: ([<a href="System-Console-CmdArgs-Explicit.html#t:Arg">Arg</a> a], <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Maybe.html#t:Maybe">Maybe</a> (<a href="System-Console-CmdArgs-Explicit.html#t:Arg">Arg</a> a))</dt><dd class="doc"><p>The unnamed arguments, a series of arguments, followed optionally by one for all remaining slots
</p></dd><dt class="src"><a name="v:modeGroupFlags" class="def">modeGroupFlags</a> :: <a href="System-Console-CmdArgs-Explicit.html#t:Group">Group</a> (<a href="System-Console-CmdArgs-Explicit.html#t:Flag">Flag</a> a)</dt><dd class="doc"><p>Groups of flags
</p></dd></dl><div class="clear"></div></div></td></tr></table></div><div class="subs instances"><p id="control.i:Mode" class="caption collapser" onclick="toggleSection('i:Mode')">Instances</p><div id="section.i:Mode" class="show"><table><tr><td class="src"><a href="System-Console-CmdArgs-Explicit.html#t:Remap">Remap</a> <a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Text-Show.html#t:Show">Show</a> (<a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a> a)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">Packer a =&gt; Packer (<a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a> a)</td><td class="doc empty">&nbsp;</td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:modeModes" class="def">modeModes</a> ::  <a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a> a -&gt; [<a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a> a]<a href="src/System-Console-CmdArgs-Explicit-Type.html#modeModes" class="link">Source</a></p><div class="doc"><p>Extract the modes from a <code><a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a></code>
</p></div></div><div class="top"><p class="src"><a name="v:modeFlags" class="def">modeFlags</a> ::  <a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a> a -&gt; [<a href="System-Console-CmdArgs-Explicit.html#t:Flag">Flag</a> a]<a href="src/System-Console-CmdArgs-Explicit-Type.html#modeFlags" class="link">Source</a></p><div class="doc"><p>Extract the flags from a <code><a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a></code>
</p></div></div><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:FlagInfo" class="def">FlagInfo</a>  <a href="src/System-Console-CmdArgs-Explicit-Type.html#FlagInfo" class="link">Source</a></p><div class="doc"><p>The <code><a href="System-Console-CmdArgs-Explicit.html#t:FlagInfo">FlagInfo</a></code> type has the following meaning:
</p><pre>              FlagReq     FlagOpt      FlagOptRare/FlagNone
 -xfoo        -x=foo      -x=foo       -x -foo
 -x foo       -x=foo      -x foo       -x foo
 -x=foo       -x=foo      -x=foo       -x=foo
 --xx foo     --xx=foo    --xx foo     --xx foo
 --xx=foo     --xx=foo    --xx=foo     --xx=foo
</pre></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:FlagReq" class="def">FlagReq</a></td><td class="doc"><p>Required argument
</p></td></tr><tr><td class="src"><a name="v:FlagOpt" class="def">FlagOpt</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a></td><td class="doc"><p>Optional argument
</p></td></tr><tr><td class="src"><a name="v:FlagOptRare" class="def">FlagOptRare</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a></td><td class="doc"><p>Optional argument that requires an = before the value
</p></td></tr><tr><td class="src"><a name="v:FlagNone" class="def">FlagNone</a></td><td class="doc"><p>No argument
</p></td></tr></table></div><div class="subs instances"><p id="control.i:FlagInfo" class="caption collapser" onclick="toggleSection('i:FlagInfo')">Instances</p><div id="section.i:FlagInfo" class="show"><table><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Eq.html#t:Eq">Eq</a> <a href="System-Console-CmdArgs-Explicit.html#t:FlagInfo">FlagInfo</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Ord.html#t:Ord">Ord</a> <a href="System-Console-CmdArgs-Explicit.html#t:FlagInfo">FlagInfo</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Text-Show.html#t:Show">Show</a> <a href="System-Console-CmdArgs-Explicit.html#t:FlagInfo">FlagInfo</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">Packer <a href="System-Console-CmdArgs-Explicit.html#t:FlagInfo">FlagInfo</a></td><td class="doc empty">&nbsp;</td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:fromFlagOpt" class="def">fromFlagOpt</a> :: <a href="System-Console-CmdArgs-Explicit.html#t:FlagInfo">FlagInfo</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a><a href="src/System-Console-CmdArgs-Explicit-Type.html#fromFlagOpt" class="link">Source</a></p><div class="doc"><p>Extract the value from inside a <code><a href="System-Console-CmdArgs-Explicit.html#v:FlagOpt">FlagOpt</a></code> or <code><a href="System-Console-CmdArgs-Explicit.html#v:FlagOptRare">FlagOptRare</a></code>, or raises an error.
</p></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:Update" class="def">Update</a> a = <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> -&gt; a -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Either.html#t:Either">Either</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> a<a href="src/System-Console-CmdArgs-Explicit-Type.html#Update" class="link">Source</a></p><div class="doc"><p>A function to take a string, and a value, and either produce an error message
   (<code>Left</code>), or a modified value (<code>Right</code>).
</p></div></div><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:Flag" class="def">Flag</a> a <a href="src/System-Console-CmdArgs-Explicit-Type.html#Flag" class="link">Source</a></p><div class="doc"><p>A flag, consisting of a list of flag names and other information.
</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:Flag" class="def">Flag</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div class="subs fields"><p class="caption">Fields</p><dl><dt class="src"><a name="v:flagNames" class="def">flagNames</a> :: [<a href="System-Console-CmdArgs-Explicit.html#t:Name">Name</a>]</dt><dd class="doc"><p>The names for the flag.
</p></dd><dt class="src"><a name="v:flagInfo" class="def">flagInfo</a> :: <a href="System-Console-CmdArgs-Explicit.html#t:FlagInfo">FlagInfo</a></dt><dd class="doc"><p>Information about a flag's arguments.
</p></dd><dt class="src"><a name="v:flagValue" class="def">flagValue</a> :: <a href="System-Console-CmdArgs-Explicit.html#t:Update">Update</a> a</dt><dd class="doc"><p>The way of processing a flag.
</p></dd><dt class="src"><a name="v:flagType" class="def">flagType</a> :: <a href="System-Console-CmdArgs-Explicit.html#t:FlagHelp">FlagHelp</a></dt><dd class="doc"><p>The type of data for the flag argument, i.e. FILE/DIR/EXT
</p></dd><dt class="src"><a name="v:flagHelp" class="def">flagHelp</a> :: <a href="System-Console-CmdArgs-Explicit.html#t:Help">Help</a></dt><dd class="doc"><p>The help message associated with this flag.
</p></dd></dl><div class="clear"></div></div></td></tr></table></div><div class="subs instances"><p id="control.i:Flag" class="caption collapser" onclick="toggleSection('i:Flag')">Instances</p><div id="section.i:Flag" class="show"><table><tr><td class="src"><a href="System-Console-CmdArgs-Explicit.html#t:Remap">Remap</a> <a href="System-Console-CmdArgs-Explicit.html#t:Flag">Flag</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Text-Show.html#t:Show">Show</a> (<a href="System-Console-CmdArgs-Explicit.html#t:Flag">Flag</a> a)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">Packer a =&gt; Packer (<a href="System-Console-CmdArgs-Explicit.html#t:Flag">Flag</a> a)</td><td class="doc empty">&nbsp;</td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:Arg" class="def">Arg</a> a <a href="src/System-Console-CmdArgs-Explicit-Type.html#Arg" class="link">Source</a></p><div class="doc"><p>An unnamed argument. Anything not starting with <code>-</code> is considered an argument,
   apart from <code>&quot;-&quot;</code> which is considered to be the argument <code>&quot;-&quot;</code>, and any arguments
   following <code>&quot;--&quot;</code>. For example:
</p><pre> programname arg1 -j - --foo arg3 -- -arg4 --arg5=1 arg6
</pre><p>Would have the arguments:
</p><pre> [&quot;arg1&quot;,&quot;-&quot;,&quot;arg3&quot;,&quot;-arg4&quot;,&quot;--arg5=1&quot;,&quot;arg6&quot;]
</pre></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:Arg" class="def">Arg</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div class="subs fields"><p class="caption">Fields</p><dl><dt class="src"><a name="v:argValue" class="def">argValue</a> :: <a href="System-Console-CmdArgs-Explicit.html#t:Update">Update</a> a</dt><dd class="doc"><p>A way of processing the argument.
</p></dd><dt class="src"><a name="v:argType" class="def">argType</a> :: <a href="System-Console-CmdArgs-Explicit.html#t:FlagHelp">FlagHelp</a></dt><dd class="doc"><p>The type of data for the argument, i.e. FILE/DIR/EXT
</p></dd><dt class="src"><a name="v:argRequire" class="def">argRequire</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Bool.html#t:Bool">Bool</a></dt><dd class="doc"><p>Is at least one of these arguments required, the command line will fail if none are set
</p></dd></dl><div class="clear"></div></div></td></tr></table></div><div class="subs instances"><p id="control.i:Arg" class="caption collapser" onclick="toggleSection('i:Arg')">Instances</p><div id="section.i:Arg" class="show"><table><tr><td class="src"><a href="System-Console-CmdArgs-Explicit.html#t:Remap">Remap</a> <a href="System-Console-CmdArgs-Explicit.html#t:Arg">Arg</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Text-Show.html#t:Show">Show</a> (<a href="System-Console-CmdArgs-Explicit.html#t:Arg">Arg</a> a)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">Packer a =&gt; Packer (<a href="System-Console-CmdArgs-Explicit.html#t:Arg">Arg</a> a)</td><td class="doc empty">&nbsp;</td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:checkMode" class="def">checkMode</a> ::  <a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a> a -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a><a href="src/System-Console-CmdArgs-Explicit-Type.html#checkMode" class="link">Source</a></p><div class="doc"><p>Check that a mode is well formed.
</p></div></div><div class="top"><p class="src"><span class="keyword">class</span>  <a name="t:Remap" class="def">Remap</a> m  <span class="keyword">where</span><a href="src/System-Console-CmdArgs-Explicit-Type.html#Remap" class="link">Source</a></p><div class="subs methods"><p class="caption">Methods</p><p class="src"><a name="v:remap" class="def">remap</a><a href="src/System-Console-CmdArgs-Explicit-Type.html#remap" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: (a -&gt; b)</td><td class="doc"><p>Embed a value
</p></td></tr><tr><td class="src">-&gt; (b -&gt; (a, a -&gt; b))</td><td class="doc"><p>Extract the mode and give a way of re-embedding
</p></td></tr><tr><td class="src">-&gt; m a</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">-&gt; m b</td><td class="doc empty">&nbsp;</td></tr></table></div></div><div class="subs instances"><p id="control.i:Remap" class="caption collapser" onclick="toggleSection('i:Remap')">Instances</p><div id="section.i:Remap" class="show"><table><tr><td class="src"><a href="System-Console-CmdArgs-Explicit.html#t:Remap">Remap</a> <a href="System-Console-CmdArgs-Explicit.html#t:Arg">Arg</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="System-Console-CmdArgs-Explicit.html#t:Remap">Remap</a> <a href="System-Console-CmdArgs-Explicit.html#t:Flag">Flag</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="System-Console-CmdArgs-Explicit.html#t:Remap">Remap</a> <a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a></td><td class="doc empty">&nbsp;</td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:remap2" class="def">remap2</a> :: <a href="System-Console-CmdArgs-Explicit.html#t:Remap">Remap</a> m =&gt; (a -&gt; b) -&gt; (b -&gt; a) -&gt; m a -&gt; m b<a href="src/System-Console-CmdArgs-Explicit-Type.html#remap2" class="link">Source</a></p></div><div class="top"><p class="src"><a name="v:modeEmpty" class="def">modeEmpty</a> ::  a -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a> a<a href="src/System-Console-CmdArgs-Explicit-Type.html#modeEmpty" class="link">Source</a></p><div class="doc"><p>Create an empty mode specifying only <code><a href="System-Console-CmdArgs-Explicit.html#v:modeValue">modeValue</a></code>. All other fields will usually be populated
   using record updates.
</p></div></div><div class="top"><p class="src"><a name="v:mode" class="def">mode</a> ::  <a href="System-Console-CmdArgs-Explicit.html#t:Name">Name</a> -&gt; a -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Help">Help</a> -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Arg">Arg</a> a -&gt; [<a href="System-Console-CmdArgs-Explicit.html#t:Flag">Flag</a> a] -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a> a<a href="src/System-Console-CmdArgs-Explicit-Type.html#mode" class="link">Source</a></p><div class="doc"><p>Create a mode with a name, an initial value, some help text, a way of processing arguments
   and a list of flags.
</p></div></div><div class="top"><p class="src"><a name="v:modes" class="def">modes</a> ::  <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> -&gt; a -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Help">Help</a> -&gt; [<a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a> a] -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a> a<a href="src/System-Console-CmdArgs-Explicit-Type.html#modes" class="link">Source</a></p><div class="doc"><p>Create a list of modes, with a program name, an initial value, some help text and the child modes.
</p></div></div><div class="top"><p class="src"><a name="v:flagNone" class="def">flagNone</a> ::  [<a href="System-Console-CmdArgs-Explicit.html#t:Name">Name</a>] -&gt; (a -&gt; a) -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Help">Help</a> -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Flag">Flag</a> a<a href="src/System-Console-CmdArgs-Explicit-Type.html#flagNone" class="link">Source</a></p><div class="doc"><p>Create a flag taking no argument value, with a list of flag names, an update function
   and some help text.
</p></div></div><div class="top"><p class="src"><a name="v:flagOpt" class="def">flagOpt</a> ::  <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> -&gt; [<a href="System-Console-CmdArgs-Explicit.html#t:Name">Name</a>] -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Update">Update</a> a -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:FlagHelp">FlagHelp</a> -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Help">Help</a> -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Flag">Flag</a> a<a href="src/System-Console-CmdArgs-Explicit-Type.html#flagOpt" class="link">Source</a></p><div class="doc"><p>Create a flag taking an optional argument value, with an optional value, a list of flag names,
   an update function, the type of the argument and some help text.
</p></div></div><div class="top"><p class="src"><a name="v:flagReq" class="def">flagReq</a> ::  [<a href="System-Console-CmdArgs-Explicit.html#t:Name">Name</a>] -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Update">Update</a> a -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:FlagHelp">FlagHelp</a> -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Help">Help</a> -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Flag">Flag</a> a<a href="src/System-Console-CmdArgs-Explicit-Type.html#flagReq" class="link">Source</a></p><div class="doc"><p>Create a flag taking a required argument value, with a list of flag names,
   an update function, the type of the argument and some help text.
</p></div></div><div class="top"><p class="src"><a name="v:flagArg" class="def">flagArg</a> ::  <a href="System-Console-CmdArgs-Explicit.html#t:Update">Update</a> a -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:FlagHelp">FlagHelp</a> -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Arg">Arg</a> a<a href="src/System-Console-CmdArgs-Explicit-Type.html#flagArg" class="link">Source</a></p><div class="doc"><p>Create an argument flag, with an update function and the type of the argument.
</p></div></div><div class="top"><p class="src"><a name="v:flagBool" class="def">flagBool</a> ::  [<a href="System-Console-CmdArgs-Explicit.html#t:Name">Name</a>] -&gt; (<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Bool.html#t:Bool">Bool</a> -&gt; a -&gt; a) -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Help">Help</a> -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Flag">Flag</a> a<a href="src/System-Console-CmdArgs-Explicit-Type.html#flagBool" class="link">Source</a></p><div class="doc"><p>Create a boolean flag, with a list of flag names, an update function and some help text.
</p></div></div><div class="top"><p class="src"><a name="v:flagHelpSimple" class="def">flagHelpSimple</a> ::  (a -&gt; a) -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Flag">Flag</a> a<a href="src/System-Console-CmdArgs-Explicit.html#flagHelpSimple" class="link">Source</a></p><div class="doc"><p>Create a help flag triggered by <code>-?</code>/<code>--help</code>.
</p></div></div><div class="top"><p class="src"><a name="v:flagHelpFormat" class="def">flagHelpFormat</a> ::  (<a href="System-Console-CmdArgs-Explicit.html#t:HelpFormat">HelpFormat</a> -&gt; <a href="System-Console-CmdArgs-Text.html#t:TextFormat">TextFormat</a> -&gt; a -&gt; a) -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Flag">Flag</a> a<a href="src/System-Console-CmdArgs-Explicit.html#flagHelpFormat" class="link">Source</a></p><div class="doc"><p>Create a help flag triggered by <code>-?</code>/<code>--help</code>. The user
   may optionally modify help by specifying the format, such as:
</p><pre> --help=all          - help for all modes
 --help=html         - help in HTML format
 --help=100          - wrap the text at 100 characters
 --help=100,one      - full text wrapped at 100 characters
</pre></div></div><div class="top"><p class="src"><a name="v:flagVersion" class="def">flagVersion</a> ::  (a -&gt; a) -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Flag">Flag</a> a<a href="src/System-Console-CmdArgs-Explicit.html#flagVersion" class="link">Source</a></p><div class="doc"><p>Create a version flag triggered by <code>-V</code>/<code>--version</code>.
</p></div></div><div class="top"><p class="src"><a name="v:flagsVerbosity" class="def">flagsVerbosity</a> ::  (<a href="System-Console-CmdArgs-Verbosity.html#t:Verbosity">Verbosity</a> -&gt; a -&gt; a) -&gt; [<a href="System-Console-CmdArgs-Explicit.html#t:Flag">Flag</a> a]<a href="src/System-Console-CmdArgs-Explicit.html#flagsVerbosity" class="link">Source</a></p><div class="doc"><p>Create verbosity flags triggered by <code>-v</code>/<code>--verbose</code> and
   <code>-q</code>/<code>--quiet</code>
</p></div></div><h1 id="g:3">Displaying help
</h1><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:HelpFormat" class="def">HelpFormat</a>  <a href="src/System-Console-CmdArgs-Explicit-Help.html#HelpFormat" class="link">Source</a></p><div class="doc"><p>Specify the format to output the help.
</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:HelpFormatDefault" class="def">HelpFormatDefault</a></td><td class="doc"><p>Equivalent to <code><a href="System-Console-CmdArgs-Explicit.html#v:HelpFormatAll">HelpFormatAll</a></code> if there is not too much text, otherwise <code><a href="System-Console-CmdArgs-Explicit.html#v:HelpFormatOne">HelpFormatOne</a></code>.
</p></td></tr><tr><td class="src"><a name="v:HelpFormatOne" class="def">HelpFormatOne</a></td><td class="doc"><p>Display only the first mode.
</p></td></tr><tr><td class="src"><a name="v:HelpFormatAll" class="def">HelpFormatAll</a></td><td class="doc"><p>Display all modes.
</p></td></tr><tr><td class="src"><a name="v:HelpFormatBash" class="def">HelpFormatBash</a></td><td class="doc"><p>Bash completion information
</p></td></tr><tr><td class="src"><a name="v:HelpFormatZsh" class="def">HelpFormatZsh</a></td><td class="doc"><p>Z shell completion information
</p></td></tr></table></div><div class="subs instances"><p id="control.i:HelpFormat" class="caption collapser" onclick="toggleSection('i:HelpFormat')">Instances</p><div id="section.i:HelpFormat" class="show"><table><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Prelude.html#t:Bounded">Bounded</a> <a href="System-Console-CmdArgs-Explicit.html#t:HelpFormat">HelpFormat</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Prelude.html#t:Enum">Enum</a> <a href="System-Console-CmdArgs-Explicit.html#t:HelpFormat">HelpFormat</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Eq.html#t:Eq">Eq</a> <a href="System-Console-CmdArgs-Explicit.html#t:HelpFormat">HelpFormat</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Ord.html#t:Ord">Ord</a> <a href="System-Console-CmdArgs-Explicit.html#t:HelpFormat">HelpFormat</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Text-Read.html#t:Read">Read</a> <a href="System-Console-CmdArgs-Explicit.html#t:HelpFormat">HelpFormat</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Text-Show.html#t:Show">Show</a> <a href="System-Console-CmdArgs-Explicit.html#t:HelpFormat">HelpFormat</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="System-Console-CmdArgs-Default.html#t:Default">Default</a> <a href="System-Console-CmdArgs-Explicit.html#t:HelpFormat">HelpFormat</a></td><td class="doc empty">&nbsp;</td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:helpText" class="def">helpText</a> ::  [<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a>] -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:HelpFormat">HelpFormat</a> -&gt; <a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a> a -&gt; [<a href="System-Console-CmdArgs-Text.html#t:Text">Text</a>]<a href="src/System-Console-CmdArgs-Explicit-Help.html#helpText" class="link">Source</a></p><div class="doc"><p>Generate a help message from a mode.  The first argument is a prefix,
   which is prepended when not using <code><a href="System-Console-CmdArgs-Explicit.html#v:HelpFormatBash">HelpFormatBash</a></code> or <code><a href="System-Console-CmdArgs-Explicit.html#v:HelpFormatZsh">HelpFormatZsh</a></code>.
</p></div></div><h1 id="g:4">Utilities for working with command lines
</h1><div class="top"><p class="src"><a name="v:expandArgsAt" class="def">expandArgsAt</a> :: [<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a>] -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> [<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a>]<a href="src/System-Console-CmdArgs-Explicit-ExpandArgsAt.html#expandArgsAt" class="link">Source</a></p><div class="doc"><p>Expand <code>@</code> directives in a list of arguments, usually obtained from <code>getArgs</code>.
   As an example, given the file <code>test.txt</code> with the lines <code>hello</code> and <code>world</code>:
</p><pre> expandArgsAt [&quot;@test.txt&quot;,&quot;!&quot;] == [&quot;hello&quot;,&quot;world&quot;,&quot;!&quot;]
</pre><p>Any <code>@</code> directives in the files will be recursively expanded (raising an error
   if there is infinite recursion).
</p></div></div><div class="top"><p class="src"><a name="v:splitArgs" class="def">splitArgs</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> -&gt; [<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a>]<a href="src/System-Console-CmdArgs-Explicit-SplitJoin.html#splitArgs" class="link">Source</a></p><div class="doc"><p>Given a string, split into the available arguments. The inverse of <code><a href="System-Console-CmdArgs-Explicit.html#v:joinArgs">joinArgs</a></code>.
</p></div></div><div class="top"><p class="src"><a name="v:joinArgs" class="def">joinArgs</a> :: [<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a>] -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a><a href="src/System-Console-CmdArgs-Explicit-SplitJoin.html#joinArgs" class="link">Source</a></p><div class="doc"><p>Given a sequence of arguments, join them together in a manner that could be used on
   the command line, giving preference to the Windows <code>cmd</code> shell quoting conventions.
</p><p>For an alternative version, intended for actual running the result in a shell, see <a href="System-Process-showCommandForUser.html">System.Process.showCommandForUser</a>
</p></div></div><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:Complete" class="def">Complete</a>  <a href="src/System-Console-CmdArgs-Explicit-Complete.html#Complete" class="link">Source</a></p><div class="doc"><p>How to complete a command line option.
   The <code><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Text-Show.html#t:Show">Show</a></code> instance is suitable for parsing from shell scripts.
</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:CompleteValue" class="def">CompleteValue</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a></td><td class="doc"><p>Complete to a particular value
</p></td></tr><tr><td class="src"><a name="v:CompleteFile" class="def">CompleteFile</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:FilePath">FilePath</a></td><td class="doc"><p>Complete to a prefix, and a file
</p></td></tr><tr><td class="src"><a name="v:CompleteDir" class="def">CompleteDir</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:FilePath">FilePath</a></td><td class="doc"><p>Complete to a prefix, and a directory
</p></td></tr></table></div><div class="subs instances"><p id="control.i:Complete" class="caption collapser" onclick="toggleSection('i:Complete')">Instances</p><div id="section.i:Complete" class="show"><table><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Eq.html#t:Eq">Eq</a> <a href="System-Console-CmdArgs-Explicit.html#t:Complete">Complete</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Ord.html#t:Ord">Ord</a> <a href="System-Console-CmdArgs-Explicit.html#t:Complete">Complete</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Text-Show.html#t:Show">Show</a> <a href="System-Console-CmdArgs-Explicit.html#t:Complete">Complete</a></td><td class="doc empty">&nbsp;</td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:complete" class="def">complete</a><a href="src/System-Console-CmdArgs-Explicit-Complete.html#complete" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="System-Console-CmdArgs-Explicit.html#t:Mode">Mode</a> a</td><td class="doc"><p>Mode specifying which arguments are allowed
</p></td></tr><tr><td class="src">-&gt; [<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a>]</td><td class="doc"><p>Arguments the user has already typed
</p></td></tr><tr><td class="src">-&gt; (<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a>, <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a>)</td><td class="doc"><p>0-based index of the argument they are currently on, and the position in that argument
</p></td></tr><tr><td class="src">-&gt; [<a href="System-Console-CmdArgs-Explicit.html#t:Complete">Complete</a>]</td><td class="doc empty">&nbsp;</td></tr></table></div><div class="doc"><p>Given a current state, return the set of commands you could type now, in preference order.
</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.9.2</p></div></body></html>