Skip to content

Commit

Permalink
Refactor help to show up on console -h as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Aug 4, 2012
1 parent d7f1bf5 commit dbe3234
Showing 1 changed file with 74 additions and 55 deletions.
129 changes: 74 additions & 55 deletions lib/Cake/Console/Command/ConsoleShell.php
Expand Up @@ -74,67 +74,86 @@ public function startup() {
}
}

public function getOptionParser() {
$description = array(
'The interactive console is a tool for testing parts of your',
'app before you write code.',
'',
'See below for a list of supported commands.'
);

$epilog = array(
'<info>Model testing</info>',
'',
'To test model results, use the name of your model without a leading $',
'e.g. Foo->find("all")',
"",
'To dynamically set associations, you can do the following:',
'',
"\tModelA bind <association> ModelB",
'',
"where the supported associations are hasOne, hasMany, belongsTo, hasAndBelongsToMany",
"",
'To dynamically remove associations, you can do the following:',
'',
"\t ModelA unbind <association> ModelB",
'',
"where the supported associations are the same as above",
"",
"To save a new field in a model, you can do the following:",
'',
"\tModelA->save(array('foo' => 'bar', 'baz' => 0))",
'',
"where you are passing a hash of data to be saved in the format",
"of field => value pairs",
"",
"To get column information for a model, use the following:",
'',
"\tModelA columns",
'',
"which returns a list of columns and their type",
"",
'<info>Route testing</info>',
"",
'To test URLs against your app\'s route configuration, type:',
"",
"\tRoute <url>",
"",
"where url is the path to your your action plus any query parameters,",
"minus the application's base path. For example:",
"",
"\tRoute /posts/view/1",
"",
"will return something like the following:",
"",
"\tarray(",
"\t [...]",
"\t 'controller' => 'posts',",
"\t 'action' => 'view',",
"\t [...]",
"\t)",
"",
'Alternatively, you can use simple array syntax to test reverse',
'To reload your routes config (Config/routes.php), do the following:',
"",
"\tRoutes reload",
"",
'To show all connected routes, do the following:',
'',
"\tRoutes show",
);
return parent::getOptionParser()
->description($description)
->epilog($epilog);
}
/**
* Prints the help message
*
* @return void
*/
public function help() {
$out = 'Console help:';
$out .= '-------------';
$out .= 'The interactive console is a tool for testing parts of your app before you';
$out .= 'write code.';
$out .= "\n";
$out .= 'Model testing:';
$out .= 'To test model results, use the name of your model without a leading $';
$out .= 'e.g. Foo->find("all")';
$out .= "\n";
$out .= 'To dynamically set associations, you can do the following:';
$out .= "\tModelA bind <association> ModelB";
$out .= "where the supported associations are hasOne, hasMany, belongsTo, hasAndBelongsToMany";
$out .= "\n";
$out .= 'To dynamically remove associations, you can do the following:';
$out .= "\t ModelA unbind <association> ModelB";
$out .= "where the supported associations are the same as above";
$out .= "\n";
$out .= "To save a new field in a model, you can do the following:";
$out .= "\tModelA->save(array('foo' => 'bar', 'baz' => 0))";
$out .= "where you are passing a hash of data to be saved in the format";
$out .= "of field => value pairs";
$out .= "\n";
$out .= "To get column information for a model, use the following:";
$out .= "\tModelA columns";
$out .= "which returns a list of columns and their type";
$out .= "\n";
$out .= "\n";
$out .= 'Route testing:';
$out .= "\n";
$out .= 'To test URLs against your app\'s route configuration, type:';
$out .= "\n";
$out .= "\tRoute <url>";
$out .= "\n";
$out .= "where url is the path to your your action plus any query parameters,";
$out .= "minus the application's base path. For example:";
$out .= "\n";
$out .= "\tRoute /posts/view/1";
$out .= "\n";
$out .= "will return something like the following:";
$out .= "\n";
$out .= "\tarray(";
$out .= "\t [...]";
$out .= "\t 'controller' => 'posts',";
$out .= "\t 'action' => 'view',";
$out .= "\t [...]";
$out .= "\t)";
$out .= "\n";
$out .= 'Alternatively, you can use simple array syntax to test reverse';
$out .= 'To reload your routes config (Config/routes.php), do the following:';
$out .= "\n";
$out .= "\tRoutes reload";
$out .= "\n";
$out .= 'To show all connected routes, do the following:';
$out .= "\tRoutes show";
$this->out($out);
$optionParser = $this->getOptionParser();
$this->out($optionParser->epilog());
}

/**
Expand Down

0 comments on commit dbe3234

Please sign in to comment.