<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to Creating</title><link>https://sourceforge.net/p/argument/wiki/Creating/</link><description>Recent changes to Creating</description><atom:link href="https://sourceforge.net/p/argument/wiki/Creating/feed" rel="self"/><language>en</language><lastBuildDate>Thu, 05 Dec 2013 01:49:35 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/argument/wiki/Creating/feed" rel="self" type="application/rss+xml"/><item><title>Creating modified by Chris DeGreef</title><link>https://sourceforge.net/p/argument/wiki/Creating/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;The very first thing you need to do when implementing the command-line processor is to &lt;strong&gt;create an instance of Argument&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Argument is written as a class called &lt;code&gt;CmdLine&lt;/code&gt;.  And it has an interface for it called &lt;code&gt;ICmdLine&lt;/code&gt;.  The interface has all of the methods you will need to interact with your command-line options.  Create an instance and optionally assign it to a variable.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="n"&gt;ICmdLine&lt;/span&gt; &lt;span class="n"&gt;arguments&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;CmdLine&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Your parser definition goes here&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code&gt;create("")&lt;/code&gt; is a static convenience method for the most popular use of Argument.  It makes some realistic assumptions in order to hide some of the details.&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;There are several more detailed ways to create an instance of Argument.&lt;/p&gt;
&lt;p&gt;You can assign a name to this instance of Argument.  The name is used when the help (&lt;code&gt;-?&lt;/code&gt;) is requested.  The default for this field is "&lt;code&gt;&lt;span&gt;[argument]&lt;/span&gt;&lt;/code&gt;" if you don't specify it.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="n"&gt;ICmdLine&lt;/span&gt; &lt;span class="n"&gt;arguments&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;CmdLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;&amp;quot;MyProgram&amp;quot;&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can specify a help message.  This will also appear in the help display (&lt;code&gt;-?&lt;/code&gt;).&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="n"&gt;ICmdLine&lt;/span&gt; &lt;span class="n"&gt;arguments&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;CmdLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;&amp;quot;MyProgram&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;&amp;quot;MyProgram will process your command-line parameters.&amp;quot;&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Optionally, you can specify the two characters that are used during the parsing of the command-line.  In Unix types of systems it is command to use dashes (&lt;code&gt;'-'&lt;/code&gt;) for the command prefix.  While in Windows it is more common to use slashes (&lt;code&gt;'/'&lt;/code&gt;).  The default that Argument uses is dashes unless you change it when creating the Argument instance.&lt;/p&gt;
&lt;p&gt;The second character is the "not", or "reset" character.  There really is no default for this in Unix.  In Windows it is the exclamation-point (&lt;code&gt;'!'&lt;/code&gt;), much like it is in a lot of languages for negation.  The default for Argument is &lt;code&gt;'!'&lt;/code&gt;.  This will probably not frequently be used on the command-line.  But it does provide an important feature that &lt;a href="/index.php?page_id=538"&gt;may be needed on occasion&lt;/a&gt;.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="n"&gt;ICmdLine&lt;/span&gt; &lt;span class="n"&gt;arguments&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;CmdLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;&amp;quot;MyProgram&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;&amp;quot;MyProgram will process your command-line parameters.&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sc"&gt;'-'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sc"&gt;'!'&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can leave the  help message off and just specify the other three parameters.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;pre&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;code&amp;quot;&lt;/span&gt; &lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;java:html:nocontrols&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;ICmdLine&lt;/span&gt; &lt;span class="n"&gt;arguments&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;CmdLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;&amp;quot;MyProgram&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sc"&gt;'-'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sc"&gt;'!'&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Chris DeGreef</dc:creator><pubDate>Thu, 05 Dec 2013 01:49:35 -0000</pubDate><guid>https://sourceforge.net658de4eb4f6057b91f4a65d2df533e2adbaa20b4</guid></item></channel></rss>