<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Connecting the dots... &#187; Console_CommandLine</title>
	<atom:link href="http://blog.rajatpandit.com/tag/console_commandline/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.rajatpandit.com</link>
	<description>Thoughts on Web Development, Infrastructure and Application Scalability</description>
	<lastBuildDate>Thu, 29 Dec 2011 13:21:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Writing a php command line based app using Console_CommandLine</title>
		<link>http://blog.rajatpandit.com/2009/10/17/writing-a-php-command-line-based-app-using-console_commandline/</link>
		<comments>http://blog.rajatpandit.com/2009/10/17/writing-a-php-command-line-based-app-using-console_commandline/#comments</comments>
		<pubDate>Sat, 17 Oct 2009 12:40:05 +0000</pubDate>
		<dc:creator>rp</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[Console_CommandLine]]></category>
		<category><![CDATA[pear]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.rajatpandit.com/?p=358</guid>
		<description><![CDATA[I am currently writing a PHP app which had to have a command line interface. I came across this excellent library in PEAR Console_CommandLine. Its core functionality is very useful...]]></description>
			<content:encoded><![CDATA[<p>I am currently writing a <a href="http://php.net">PHP</a> app which had to have a command line interface. I came across this excellent library in <a href="http://pear.php.net">PEAR</a> <a href="http://pear.php.net/manual/en/package.console.console-commandline.php">Console_CommandLine</a>. Its core functionality is very useful out of the box and in case you need to do something really fancy, there is nothing stopping you from extending it further. </p>
<p>Here is a quick example for anyone interested in getting up and running with it.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
require_once 'Console/CommandLine.php';

$parser = new Console_CommandLine();
$parser-&gt;description = 'A fantastic command line program that does nothing.';
$parser-&gt;version = '1.5.0';
$parser-&gt;addOption('filename', array(
    'short_name'  =&gt; '-f',
    'long_name'   =&gt; '--file',
    'description' =&gt; 'write report to FILE',
    'help_name'   =&gt; 'FILE',
    'action'      =&gt; 'StoreString'
));
$parser-&gt;addOption('quiet', array(
    'short_name'  =&gt; '-q',
    'long_name'   =&gt; '--quiet',
    'description' =&gt; &quot;don't print status messages to stdout&quot;,
    'action'      =&gt; 'StoreTrue'
));
try {
    $result = $parser-&gt;parse();
    // do something with the result object
    print_r($result-&gt;options);
    print_r($result-&gt;args);
} catch (Exception $exc) {
    $parser-&gt;displayError($exc-&gt;getMessage());
}
</pre>
<p>gives the output for <code>yourscript -help</code></p>
<pre class="brush: bash; title: ; notranslate">
A fantastic command line program that does nothing.

Usage:
  tmp.php [options]

Options:
  -f FILE, --file=FILE  write report to FILE
  -q, --quiet           don't print status messages to stdout
  -h, --help            show this help message and exit
  --version             show the program version and exit
</pre>
<p>Details for options/configuration:<a href="http://pear.php.net/manual/en/package.console.console-commandline.options.php"> http://pear.php.net/manual/en/package.console.console-commandline.options.php</a></p>
<p>Details for command line arguments: <a href="http://pear.php.net/manual/en/package.console.console-commandline.arguments.php">http://pear.php.net/manual/en/package.console.console-commandline.arguments.php</a></p>
<p>Details for extending lib: <a href="http://pear.php.net/manual/en/package.console.console-commandline.extending.php">http://pear.php.net/manual/en/package.console.console-commandline.extending.php</a></p>
<div id="in_post_ad_bottom_1" style="clear:both;margin:0;padding:0;"><div class="brp-bp-234">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-4254382394977039";
/* brp-234x60-bp */
google_ad_slot = "7787511801";
google_ad_width = 234;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<div class="brp-bp-234">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-4254382394977039";
/* brp-234x60-BP-1 */
google_ad_slot = "9111022353";
google_ad_width = 234;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div></div><div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://blog.rajatpandit.com/2009/10/17/writing-a-php-command-line-based-app-using-console_commandline/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

