<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!--Rendered using the Haskell Html Library v0.2--> <HTML ><HEAD ><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8" ><TITLE >CommandLine</TITLE ><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css" ><SCRIPT SRC="haddock-util.js" TYPE="text/javascript" ></SCRIPT ><SCRIPT TYPE="text/javascript" >window.onload = function () {setSynopsis("mini_CommandLine.html")};</SCRIPT ></HEAD ><BODY ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="topbar" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD ><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" " ></TD ><TD CLASS="title" >darcs-2.4.4: a distributed, interactive, smart revision control system</TD ><TD CLASS="topbut" ><A HREF="index.html" >Contents</A ></TD ><TD CLASS="topbut" ><A HREF="doc-index.html" >Index</A ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="modulebar" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD ><FONT SIZE="6" >CommandLine</FONT ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" >Description</TD ></TR ><TR ><TD 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 ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" >Synopsis</TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="#v%3AparseCmd" >parseCmd</A > :: FTable -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A > -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Either.html#t%3AEither" >Either</A > <A HREF="/usr/share/doc/ghc/html/libraries/parsec-2.1.0.1/Text-ParserCombinators-Parsec-Error.html#t%3AParseError" >ParseError</A > ([<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A >], <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Bool.html#t%3ABool" >Bool</A >)</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AaddUrlencoded" >addUrlencoded</A > :: FTable -> FTable</TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" >Documentation</TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:parseCmd" ><A NAME="v%3AparseCmd" ></A ></A ><B >parseCmd</B > :: FTable -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A > -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Either.html#t%3AEither" >Either</A > <A HREF="/usr/share/doc/ghc/html/libraries/parsec-2.1.0.1/Text-ParserCombinators-Parsec-Error.html#t%3AParseError" >ParseError</A > ([<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A >], <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Bool.html#t%3ABool" >Bool</A >)</TD ></TR ><TR ><TD CLASS="doc" >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 [(s,<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 > </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:addUrlencoded" ><A NAME="v%3AaddUrlencoded" ></A ></A ><B >addUrlencoded</B > :: FTable -> FTable</TD ></TR ><TR ><TD CLASS="doc" >for every mapping (c,s), add a mapping with uppercase c and the urlencoded string s </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="botbar" >Produced by <A HREF="http://www.haskell.org/haddock/" >Haddock</A > version 2.6.0</TD ></TR ></TABLE ></BODY ></HTML >