<!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>CommandLine</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_CommandLine.html");}; //]]> </script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/CommandLine.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">darcs-2.8.3: a distributed, interactive, smart revision control system</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Portability</th><td>portable</td></tr><tr><th>Stability</th><td>experimental</td></tr><tr><th>Maintainer</th><td>darcs-devel@darcs.net</td></tr><tr><th>Safe Haskell</th><td>Safe-Infered</td></tr></table><p class="caption">CommandLine</p></div><div id="description"><p class="caption">Description</p><div class="doc"><p>|A parser for commandlines, returns an arg list and expands format strings given in a translation table. Additionally the commandline can end with <a href="%<.html">%<</a> specifying that the command expects input on stdin. </p><p>Some tests for the parser. </p><pre> formatTable = [('s',"<insert subject here>"), ('a',"<insert author here>")] testParser :: (Show a, Eq a) => Parser a -> String -> a -> a testParser p s ok = case parse p "" s of Left e -> error $ "Parser failed with: " ++ (show e) Right res -> if res == ok then res else error $ "Parser failed: got " ++ (show res) ++ ", expected " ++ (show ok) testCases = [("a b",(["a","b"], False)), ("a b %<",(["a","b"], True)), ("a b %< ",(["a","b"], True)), ("\"arg0 contains spaces \\\"quotes\\\"\" b", (["arg0 contains spaces \"quotes\"","b"],False)), ("a %s %<",(["a","<insert subject here>"], True))] runTests = map (uncurry $ testParser (commandline formatTable)) testCases </pre></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:parseCmd">parseCmd</a> :: FTable -> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-String.html#t:String">String</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Either.html#t:Either">Either</a> <a href="/usr/share/doc/ghc/html/libraries/parsec-3.1.2/Text-Parsec-Error.html#t:ParseError">ParseError</a> ([<a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-String.html#t:String">String</a>], <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Bool.html#t:Bool">Bool</a>)</li><li class="src short"><a href="#v:addUrlencoded">addUrlencoded</a> :: FTable -> FTable</li></ul></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><a name="v:parseCmd" class="def">parseCmd</a> :: FTable -> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-String.html#t:String">String</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Either.html#t:Either">Either</a> <a href="/usr/share/doc/ghc/html/libraries/parsec-3.1.2/Text-Parsec-Error.html#t:ParseError">ParseError</a> ([<a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-String.html#t:String">String</a>], <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Bool.html#t:Bool">Bool</a>)<a href="src/CommandLine.html#parseCmd" class="link">Source</a></p><div class="doc"><p>parse a commandline returning a list of strings (intended to be used as argv) and a bool value which specifies if the command expects input on stdin format specifiers with a mapping in ftable are accepted and replaced by the given strings. E.g. if the ftable is [(<code>s</code>,<a href="Some subject.html">Some subject</a>)], then <a href="%s.html">%s</a> is replaced by <a href="Some subject.html">Some subject</a> </p></div></div><div class="top"><p class="src"><a name="v:addUrlencoded" class="def">addUrlencoded</a> :: FTable -> FTable<a href="src/CommandLine.html#addUrlencoded" class="link">Source</a></p><div class="doc"><p>for every mapping (c,s), add a mapping with uppercase c and the urlencoded string s </p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.10.0</p></div></body></html>