|
|
@@ -14,6 +14,7 @@
|
|
|
*/
|
|
|
namespace Cake\Console;
|
|
|
|
|
|
+use Cake\Console\Exception\ConsoleException;
|
|
|
use Cake\Utility\Text;
|
|
|
use SimpleXmlElement;
|
|
|
|
|
|
@@ -51,6 +52,13 @@ class HelpFormatter
|
|
|
protected $_parser;
|
|
|
|
|
|
/**
|
|
|
+ * Alias to display in the output.
|
|
|
+ *
|
|
|
+ * @var string
|
|
|
+ */
|
|
|
+ protected $_alias = 'cake';
|
|
|
+
|
|
|
+ /**
|
|
|
* Build the help formatter for an OptionParser
|
|
|
*
|
|
|
* @param \Cake\Console\ConsoleOptionParser $parser The option parser help is being generated for.
|
|
|
@@ -61,6 +69,21 @@ class HelpFormatter
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Set the alias
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ * @throws \Cake\Console\Exception\ConsoleException When alias is not a string.
|
|
|
+ */
|
|
|
+ public function setAlias($alias)
|
|
|
+ {
|
|
|
+ if (is_string($alias)) {
|
|
|
+ $this->_alias = $alias;
|
|
|
+ } else {
|
|
|
+ throw new ConsoleException('Alias must be of type string.');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* Get the help as formatted text suitable for output on the command line.
|
|
|
*
|
|
|
* @param int $width The width of the help output.
|
|
|
@@ -91,7 +114,7 @@ class HelpFormatter
|
|
|
]);
|
|
|
}
|
|
|
$out[] = '';
|
|
|
- $out[] = sprintf('To see help on a subcommand use <info>`cake %s [subcommand] --help`</info>', $parser->getCommand());
|
|
|
+ $out[] = sprintf('To see help on a subcommand use <info>`' . $this->_alias . ' %s [subcommand] --help`</info>', $parser->getCommand());
|
|
|
$out[] = '';
|
|
|
}
|
|
|
|
|
|
@@ -142,7 +165,7 @@ class HelpFormatter
|
|
|
*/
|
|
|
protected function _generateUsage()
|
|
|
{
|
|
|
- $usage = ['cake ' . $this->_parser->getCommand()];
|
|
|
+ $usage = [$this->_alias . ' ' . $this->_parser->getCommand()];
|
|
|
$subcommands = $this->_parser->subcommands();
|
|
|
if (!empty($subcommands)) {
|
|
|
$usage[] = '[subcommand]';
|