Source for file Default.php
Documentation is available at Default.php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
* This file is part of the PEAR Console_CommandLine package.
* LICENSE: This source file is subject to the MIT license that is available
* through the world-wide-web at the following URI:
* http://opensource.org/licenses/mit-license.php
* @package Console_CommandLine
* @author David JEAN LOUIS <izimobil@gmail.com>
* @copyright 2007 David JEAN LOUIS
* @license http://opensource.org/licenses/mit-license.php MIT License
* @link http://pear.php.net/package/Console_CommandLine
* @since File available since release 0.1.0
* The renderer interface.
require_once 'Console/CommandLine/Renderer.php';
* Console_CommandLine default renderer.
* @package Console_CommandLine
* @author David JEAN LOUIS <izimobil@gmail.com>
* @copyright 2007 David JEAN LOUIS
* @license http://opensource.org/licenses/mit-license.php MIT License
* @version Release: 1.2.0
* @link http://pear.php.net/package/Console_CommandLine
* @since Class available since release 0.1.0
* Integer that define the max width of the help text.
* @var integer $line_width Line width
* Integer that define the max width of the help text.
* @var integer $line_width Line width
* An instance of Console_CommandLine.
* @var Console_CommandLine $parser The parser
* @param object $parser A Console_CommandLine instance
* Returns the full usage message.
* @return string The usage message
* Returns a formatted error message.
* @param string $error The error message to format
* @return string The error string
public function error($error)
$ret = 'Error: ' . $error . "\n";
array ('progname' => $name))) . "\n";
array ('progname' => $name))) . "\n";
* Returns the program version string.
* @return string The version string
'progname' => $this->name(),
* Returns the full name of the program or the sub command
* @return string The name of the program
protected function name()
if (count($parent->options ) > 0 ) {
$name = $parent->name . ' ' . $name;
$parent = $parent->parent;
return $this->wrap($name);
* Returns the command line description message.
* @return string The description message
* Returns the command line usage message
* @return string the usage message
$ret = $usage . ' ' . $this->name();
$arg_str = $arg->help_name;
$arg_str .= '1 ' . $arg->help_name . '2 ...';
$arg_str = '[' . $arg_str . ']';
// commandUsageLine() {{{
* Returns the command line usage message for subcommands.
* @return string The usage line
$ret = ' ' . $this->name();
if (!$hasArgs && count($command->args ) > 0 ) {
if (!$hasOptions && ($command->add_help_option ||
$command->add_version_option || count($command->options ) > 0 )) {
* Render the arguments list that will be displayed to the user, you can
* override this method if you want to change the look of the list.
* @return string The formatted argument list
$argstr = ' ' . $arg->toString ();
$args[] = array ($argstr, $arg->description );
foreach ($args as $arg) {
$text = str_pad($arg[0 ], $col) . ' ' . $arg[1 ];
* Render the options list that will be displayed to the user, you can
* override this method if you want to change the look of the list.
* @return string The formatted option list
$optstr = $option->toString ($delim);
$lines[0 ] = ' ' . $lines[0 ];
$lines[1 ] = ' ' . $lines[1 ];
$options[] = array ($lines, $option->description );
foreach ($options as $option) {
if (count($option[0 ]) > 1 ) {
$text = str_pad($option[0 ][1 ], $col) . ' ' . $option[1 ];
$pre = $option[0 ][0 ] . "\n";
$text = str_pad($option[0 ][0 ], $col) . ' ' . $option[1 ];
$ret .= "\n" . $pre . $this->columnWrap($text, $col+2 );
* Render the command list that will be displayed to the user, you can
* override this method if you want to change the look of the list.
* @return string The formatted subcommand list
$cmdname = ' ' . $cmdname;
$commands[] = array ($cmdname, $command->description , $command->aliases );
foreach ($commands as $command) {
$text = str_pad($command[0 ], $col) . ' ' . $command[1 ];
if ($aliasesCount = count($command[2 ])) {
$text .= $aliasesCount > 1 ? 'aliases: ' : 'alias: ';
foreach ($command[2 ] as $alias) {
* Wraps the text passed to the method.
* @param string $text The text to wrap
* @param int $lw The column width (defaults to line_width property)
* @return string The wrapped text
protected function wrap($text, $lw=null )
return wordwrap($text, $lw, "\n", false );
* Wraps the text passed to the method at the specified width.
* @param string $text The text to wrap
* @param int $cw The wrap width
* @return string The wrapped text
foreach ($tokens as $token) {
Documentation generated on Mon, 11 Mar 2019 15:51:31 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|