mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-07 12:36:25 +00:00
Adding documentation for Cake console dispatcher
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5298 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
75ccff3c3e
commit
8150647bd1
1 changed files with 32 additions and 19 deletions
|
@ -38,85 +38,94 @@ class ShellDispatcher {
|
||||||
* Standard input stream.
|
* Standard input stream.
|
||||||
*
|
*
|
||||||
* @var filehandle
|
* @var filehandle
|
||||||
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $stdin;
|
var $stdin;
|
||||||
/**
|
/**
|
||||||
* Standard output stream.
|
* Standard output stream.
|
||||||
*
|
*
|
||||||
* @var filehandle
|
* @var filehandle
|
||||||
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $stdout;
|
var $stdout;
|
||||||
/**
|
/**
|
||||||
* Standard error stream.
|
* Standard error stream.
|
||||||
*
|
*
|
||||||
* @var filehandle
|
* @var filehandle
|
||||||
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $stderr;
|
var $stderr;
|
||||||
/**
|
/**
|
||||||
* Contains command switches parsed from the command line.
|
* Contains command switches parsed from the command line.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $params = array();
|
var $params = array();
|
||||||
/**
|
/**
|
||||||
* Contains arguments parsed from the command line.
|
* Contains arguments parsed from the command line.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $args = array();
|
var $args = array();
|
||||||
/**
|
/**
|
||||||
* The file name of the shell that was invoked.
|
* The file name of the shell that was invoked.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $shell = null;
|
var $shell = null;
|
||||||
/**
|
/**
|
||||||
* The class name of the shell that was invoked.
|
* The class name of the shell that was invoked.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $shellClass = null;
|
var $shellClass = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The command called if public methods are available.
|
* The command called if public methods are available.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $shellCommand = null;
|
var $shellCommand = null;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The path location of shells.
|
* The path locations of shells.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $shellPaths = array();
|
var $shellPaths = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The path to the current shell location.
|
* The path to the current shell location.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $shellPath = null;
|
var $shellPath = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the shell in camelized.
|
* The name of the shell in camelized.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $shellName = null;
|
var $shellName = null;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs this ShellDispatcher instance.
|
* Constructs this ShellDispatcher instance.
|
||||||
*
|
*
|
||||||
* @param array $args the argv.
|
* @param array $args the argv.
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
function ShellDispatcher($args = array()) {
|
function ShellDispatcher($args = array()) {
|
||||||
$this->__construct($args);
|
$this->__construct($args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param array $args the argv.
|
||||||
|
*/
|
||||||
function __construct($args = array()) {
|
function __construct($args = array()) {
|
||||||
$this->__initConstants();
|
$this->__initConstants();
|
||||||
$this->parseParams($args);
|
$this->parseParams($args);
|
||||||
|
@ -127,7 +136,7 @@ class ShellDispatcher {
|
||||||
/**
|
/**
|
||||||
* Defines core configuration.
|
* Defines core configuration.
|
||||||
*
|
*
|
||||||
* @return void
|
* @access private
|
||||||
*/
|
*/
|
||||||
function __initConstants() {
|
function __initConstants() {
|
||||||
if (function_exists('ini_set')) {
|
if (function_exists('ini_set')) {
|
||||||
|
@ -146,10 +155,9 @@ class ShellDispatcher {
|
||||||
/**
|
/**
|
||||||
* Defines current working environment.
|
* Defines current working environment.
|
||||||
*
|
*
|
||||||
* @return void
|
* @access private
|
||||||
*/
|
*/
|
||||||
function __initEnvironment() {
|
function __initEnvironment() {
|
||||||
|
|
||||||
$this->stdin = fopen('php://stdin', 'r');
|
$this->stdin = fopen('php://stdin', 'r');
|
||||||
$this->stdout = fopen('php://stdout', 'w');
|
$this->stdout = fopen('php://stdout', 'w');
|
||||||
$this->stderr = fopen('php://stderr', 'w');
|
$this->stderr = fopen('php://stderr', 'w');
|
||||||
|
@ -189,7 +197,8 @@ class ShellDispatcher {
|
||||||
/**
|
/**
|
||||||
* Initializes the environment and loads the Cake core.
|
* Initializes the environment and loads the Cake core.
|
||||||
*
|
*
|
||||||
* @return boolean Returns false if loading failed.
|
* @return boolean Success.
|
||||||
|
* @access private
|
||||||
*/
|
*/
|
||||||
function __bootstrap() {
|
function __bootstrap() {
|
||||||
|
|
||||||
|
@ -233,7 +242,7 @@ class ShellDispatcher {
|
||||||
/**
|
/**
|
||||||
* Dispatches a CLI request
|
* Dispatches a CLI request
|
||||||
*
|
*
|
||||||
* @return void
|
* @access public
|
||||||
*/
|
*/
|
||||||
function dispatch() {
|
function dispatch() {
|
||||||
$this->stdout("\nWelcome to CakePHP v" . Configure::version() . " Console");
|
$this->stdout("\nWelcome to CakePHP v" . Configure::version() . " Console");
|
||||||
|
@ -351,6 +360,7 @@ class ShellDispatcher {
|
||||||
* @param mixed $options Array or string of options.
|
* @param mixed $options Array or string of options.
|
||||||
* @param string $default Default input value.
|
* @param string $default Default input value.
|
||||||
* @return Either the default value, or the user-provided input.
|
* @return Either the default value, or the user-provided input.
|
||||||
|
* @access public
|
||||||
*/
|
*/
|
||||||
function getInput($prompt, $options = null, $default = null) {
|
function getInput($prompt, $options = null, $default = null) {
|
||||||
if (!is_array($options)) {
|
if (!is_array($options)) {
|
||||||
|
@ -377,6 +387,7 @@ class ShellDispatcher {
|
||||||
*
|
*
|
||||||
* @param string $string String to output.
|
* @param string $string String to output.
|
||||||
* @param boolean $newline If true, the outputs gets an added newline.
|
* @param boolean $newline If true, the outputs gets an added newline.
|
||||||
|
* @access public
|
||||||
*/
|
*/
|
||||||
function stdout($string, $newline = true) {
|
function stdout($string, $newline = true) {
|
||||||
if ($newline) {
|
if ($newline) {
|
||||||
|
@ -389,6 +400,7 @@ class ShellDispatcher {
|
||||||
* Outputs to the stderr filehandle.
|
* Outputs to the stderr filehandle.
|
||||||
*
|
*
|
||||||
* @param string $string Error text to output.
|
* @param string $string Error text to output.
|
||||||
|
* @access public
|
||||||
*/
|
*/
|
||||||
function stderr($string) {
|
function stderr($string) {
|
||||||
fwrite($this->stderr, 'Error: '. $string);
|
fwrite($this->stderr, 'Error: '. $string);
|
||||||
|
@ -396,8 +408,8 @@ class ShellDispatcher {
|
||||||
/**
|
/**
|
||||||
* Parses command line options
|
* Parses command line options
|
||||||
*
|
*
|
||||||
* @param array $params
|
* @param array $params Parameters to parse
|
||||||
* @return void
|
* @access public
|
||||||
*/
|
*/
|
||||||
function parseParams($params) {
|
function parseParams($params) {
|
||||||
$out = array();
|
$out = array();
|
||||||
|
@ -444,6 +456,7 @@ class ShellDispatcher {
|
||||||
* Removes first argument and shifts other arguments up
|
* Removes first argument and shifts other arguments up
|
||||||
*
|
*
|
||||||
* @return boolean False if there are no arguments
|
* @return boolean False if there are no arguments
|
||||||
|
* @access public
|
||||||
*/
|
*/
|
||||||
function shiftArgs() {
|
function shiftArgs() {
|
||||||
if (empty($this->args)) {
|
if (empty($this->args)) {
|
||||||
|
@ -456,7 +469,7 @@ class ShellDispatcher {
|
||||||
/**
|
/**
|
||||||
* Shows console help
|
* Shows console help
|
||||||
*
|
*
|
||||||
* @return void
|
* @access public
|
||||||
*/
|
*/
|
||||||
function help() {
|
function help() {
|
||||||
$this->stdout("Current Paths:");
|
$this->stdout("Current Paths:");
|
||||||
|
|
Loading…
Add table
Reference in a new issue