<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments for xurei design</title>
	<atom:link href="http://www.xurei-design.be/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.xurei-design.be</link>
	<description></description>
	<lastBuildDate>Wed, 09 Nov 2011 12:31:45 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>Comment on A PHP Command-line interface parser by xurei</title>
		<link>http://www.xurei-design.be/2011/10/a-php-command-line-interface-parser/#comment-11</link>
		<dc:creator>xurei</dc:creator>
		<pubDate>Wed, 09 Nov 2011 12:31:45 +0000</pubDate>
		<guid isPermaLink="false">http://olivier-laptop/xureidesign/?p=37#comment-11</guid>
		<description>This is just an example, showing what can be done with it. You can make this code way smaller.
Beside, you can reduce the size of the code if you want just a simple command line parser :

	you can remove the description of each argument if you don&#039;t need them
	you can get rid of the extension of the parser class, if you don&#039;t need a different help message
	you can remove the help message shown by default


... which will give you this shorter piece of code :

require_once(&#039;CliParser.inc&#039;);

$clistring = new CliTokenString(&quot;-c&quot;);
$clihelp = new CliTokenBoolean(&quot;--help&quot;);
$clisingleton = new CliTokenBoolean(&quot;-e&quot;);
$clibool = new CliTokenBoolean(&quot;-b&quot;);
$clidir = new CliTokenDirectory(&quot;-d&quot;);
$clifile = new CliTokenDirectory(&quot;-f&quot;);
$cliint = new CliTokenInteger(&quot;-i&quot;);
$clienum = new CliTokenEnum(&quot;-enum&quot;, array(&#039;the&#039;, &#039;different&#039;, &#039;values&#039;, &#039;accepted&#039;));

//Building the parser and parsing the arguments
$cli = new CliParser($_SERVER[&quot;argv&quot;]);
$cli-&gt;register($clihelp, false); // false because it not require an argument
$cli-&gt;register($clistring);
$cli-&gt;register($clisingleton, false); // false because it not require an argument
$cli-&gt;register($clibool);
$cli-&gt;register($clidir);
$cli-&gt;register($clifile);
$cli-&gt;register($cliint);
$cli-&gt;register($clienum);
$cli-&gt;parse();

//Showing the options
var_dump($clistring-&gt;getValue());
var_dump($clisingleton-&gt;getValue());
var_dump($clibool-&gt;getValue());
var_dump($clidir-&gt;getValue());
var_dump($clifile-&gt;getValue());
var_dump($cliint-&gt;getValue());

//Showing the non options
var_dump($cli-&gt;getNonOptions());
 

But yes, you can make smaller, dirtier, non-reusable code. 
Also, remember that it is an extension of something already existing. Most of the setup code doesn&#039;t come from me.

However, what would you do to make this smaller ?</description>
		<content:encoded><![CDATA[<p>This is just an example, showing what can be done with it. You can make this code way smaller.<br />
Beside, you can reduce the size of the code if you want just a simple command line parser :</p>
<p>	you can remove the description of each argument if you don&#8217;t need them<br />
	you can get rid of the extension of the parser class, if you don&#8217;t need a different help message<br />
	you can remove the help message shown by default</p>
<p>&#8230; which will give you this shorter piece of code :</p>
<p>require_once(&#8216;CliParser.inc&#8217;);</p>
<p>$clistring = new CliTokenString(&#8220;-c&#8221;);<br />
$clihelp = new CliTokenBoolean(&#8220;&#8211;help&#8221;);<br />
$clisingleton = new CliTokenBoolean(&#8220;-e&#8221;);<br />
$clibool = new CliTokenBoolean(&#8220;-b&#8221;);<br />
$clidir = new CliTokenDirectory(&#8220;-d&#8221;);<br />
$clifile = new CliTokenDirectory(&#8220;-f&#8221;);<br />
$cliint = new CliTokenInteger(&#8220;-i&#8221;);<br />
$clienum = new CliTokenEnum(&#8220;-enum&#8221;, array(&#8216;the&#8217;, &#8216;different&#8217;, &#8216;values&#8217;, &#8216;accepted&#8217;));</p>
<p>//Building the parser and parsing the arguments<br />
$cli = new CliParser($_SERVER["argv"]);<br />
$cli-&gt;register($clihelp, false); // false because it not require an argument<br />
$cli-&gt;register($clistring);<br />
$cli-&gt;register($clisingleton, false); // false because it not require an argument<br />
$cli-&gt;register($clibool);<br />
$cli-&gt;register($clidir);<br />
$cli-&gt;register($clifile);<br />
$cli-&gt;register($cliint);<br />
$cli-&gt;register($clienum);<br />
$cli-&gt;parse();</p>
<p>//Showing the options<br />
var_dump($clistring-&gt;getValue());<br />
var_dump($clisingleton-&gt;getValue());<br />
var_dump($clibool-&gt;getValue());<br />
var_dump($clidir-&gt;getValue());<br />
var_dump($clifile-&gt;getValue());<br />
var_dump($cliint-&gt;getValue());</p>
<p>//Showing the non options<br />
var_dump($cli-&gt;getNonOptions());</p>
<p>But yes, you can make smaller, dirtier, non-reusable code.<br />
Also, remember that it is an extension of something already existing. Most of the setup code doesn&#8217;t come from me.</p>
<p>However, what would you do to make this smaller ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on A PHP Command-line interface parser by Teerd Phyre</title>
		<link>http://www.xurei-design.be/2011/10/a-php-command-line-interface-parser/#comment-10</link>
		<dc:creator>Teerd Phyre</dc:creator>
		<pubDate>Wed, 09 Nov 2011 01:23:27 +0000</pubDate>
		<guid isPermaLink="false">http://olivier-laptop/xureidesign/?p=37#comment-10</guid>
		<description>So, are you primarily a Java programmer? ;)

Seriously, dude, this is way too much code for setup...</description>
		<content:encoded><![CDATA[<p>So, are you primarily a Java programmer? <img src='http://www.xurei-design.be/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Seriously, dude, this is way too much code for setup&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>

