mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Refactor help to show up on console -h as well.
This commit is contained in:
parent
d7f1bf52b1
commit
dbe3234b56
1 changed files with 74 additions and 55 deletions
|
@ -74,67 +74,86 @@ class ConsoleShell extends AppShell {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
* Prints the help message
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function help() {
|
public function help() {
|
||||||
$out = 'Console help:';
|
$optionParser = $this->getOptionParser();
|
||||||
$out .= '-------------';
|
$this->out($optionParser->epilog());
|
||||||
$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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue