Re: [Console_CommandLine] example section in xml file

From: Date: Mon, 08 Dec 2008 22:20:30 +0000
Subject: Re: [Console_CommandLine] example section in xml file
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-29492@lists.php.net to get a copy of this message
Reuben Cummings a écrit :
Hi, I would like to add an "Examples" section via the xml file so that the help screen will show the following at the end (this is an example taken from the perl beancounter module) Examples:
    beancounter update --forceupdate today
    beancounter addportfolio SUNW:100:USD:401k:joe:14.10:20011205 VOD.L:50:GBP
    beancounter addstock CBOT LNUX RHAT COR.TO
    beancounter backpopulate MSFT SUNW --prevdate 19940101 --date 19981231
    beancounter fxbackpopulate EUR --prevdate 20010101 --date yesterday
How would I go about doing this? Reuben
You have 2 alternatives: * if you don't mind putting the examples after the description and before the usage, you can just add them to the <description/> node of your xml file (in a cdata for example); * or you can create a custom renderer and override the usage() method: (code not tested) <?php require_once 'Console/CommandLine/Renderer/Default.php'; class CustomRenderer extends Console_CommandLine_Renderer_Default {
    public function usage()
    {
        $ret  = parent::usage();
        $ret .= 'add whatever you want here...';
        return $ret;
    }
} // I assume you have a Console_CommandLine instance $renderer = new CustomRenderer(); $parser->accept($renderer); // then the usual stuff, parse() ... ?> -- David

« previous php.pear.general (#29492) next »