PHP Class Moosh\MooshCommand

Show file Open project: tmuras/moosh Class Usage Examples

Public Properties

Property Type Description
$BOOTSTRAP_CONFIG set CLI_SCRIPT, ABORT_AFTER_CONFIG and include config.php
$BOOTSTRAP_FULL set CLI_SCRIPT and include config.php
$BOOTSTRAP_FULL_NOCLI no CLI_SCRIPT, include config.php
$BOOTSTRAP_NONE Do not include config.php at all
$arguments
$cwd string Current working directory
$defaults array Default global options
$expandedOptions array After expanding
$finalOptions array Before expanding
$mooshDir string moosh installation directory.
$options
$relativeDir string Directory relative to the current Moodle root dir.
$spec GetOptionKit\OptionSpecCollection
$topDir string Top Moodle installation directory.
$verbose

Protected Properties

Property Type Description
$argumentNames array
$group
$maxArguments integer .
$minArguments integer How many arguments minimum are required.
$name
$parsedOptions GetOptionKit\OptionResult
$pluginInfo array Possible information on plugin in a current directory.
$session array Temporary session information.

Public Methods

Method Description
__construct ( $name, $group = NULL )
addArgument ( string $name, $type = ARG_GENERIC ) Define required argument. Call function again to add another argument.
addOption ( $optionSpec, $description = NULL, $default = NULL )
bootstrapLevel ( ) : integer Should command be bootstrapped as CLI_SCRIPT and include config.php?
checkDirArg ( $name )
checkFileArg ( $name )
checkPathArg ( $name )
expandOptions ( ) Make the special replacements of %s in the options
expandOptionsManually ( $replacements ) Make the special replacements of %s in the options with custom list of arguments
getName ( )
printOptions ( )
processOptions ( $defaults )
requireHomeWriteable ( ) : integer Does the command require writing to ~/.moosh/ directory?
setArguments ( $arguments )
setParsedOptions ( $parsedOptions )
setPluginInfo ( $pluginInfo )
status ( )

Protected Methods

Method Description
getArgumentsHelp ( ) Can be overwritten by child classes to provide custom description.
getLangCategory ( )
loadSession ( ) Loads temporary session information from the temp file.
onErrorHelp ( ) : string Overwrite to display extra information (e.g. help) when error occured (e.g. wrong arguments were given)
saveSession ( ) Saves session information to the temp file.

Method Details

__construct() public method

public __construct ( $name, $group = NULL )

addArgument() public method

Define required argument. Call function again to add another argument.
public addArgument ( string $name, $type = ARG_GENERIC )
$name string

addOption() public method

public addOption ( $optionSpec, $description = NULL, $default = NULL )

bootstrapLevel() public method

Should command be bootstrapped as CLI_SCRIPT and include config.php?
public bootstrapLevel ( ) : integer
return integer

checkDirArg() public method

public checkDirArg ( $name )

checkFileArg() public method

public checkFileArg ( $name )

checkPathArg() public method

public checkPathArg ( $name )

expandOptions() public method

Make the special replacements of %s in the options
public expandOptions ( )

expandOptionsManually() public method

Make the special replacements of %s in the options with custom list of arguments
public expandOptionsManually ( $replacements )

getArgumentsHelp() protected method

Can be overwritten by child classes to provide custom description.
protected getArgumentsHelp ( )

getLangCategory() protected method

protected getLangCategory ( )

getName() public method

public getName ( )

loadSession() protected method

Loads temporary session information from the temp file.
protected loadSession ( )

onErrorHelp() protected method

Overwrite to display extra information (e.g. help) when error occured (e.g. wrong arguments were given)
protected onErrorHelp ( ) : string
return string

printOptions() public method

public printOptions ( )

processOptions() public method

public processOptions ( $defaults )

requireHomeWriteable() public method

Does the command require writing to ~/.moosh/ directory?
public requireHomeWriteable ( ) : integer
return integer

saveSession() protected method

Saves session information to the temp file.
protected saveSession ( )

setArguments() public method

public setArguments ( $arguments )

setParsedOptions() public method

public setParsedOptions ( $parsedOptions )

setPluginInfo() public method

public setPluginInfo ( $pluginInfo )

status() public method

public status ( )

Property Details

$BOOTSTRAP_CONFIG public static property

set CLI_SCRIPT, ABORT_AFTER_CONFIG and include config.php
public static $BOOTSTRAP_CONFIG

$BOOTSTRAP_FULL public static property

set CLI_SCRIPT and include config.php
public static $BOOTSTRAP_FULL

$BOOTSTRAP_FULL_NOCLI public static property

no CLI_SCRIPT, include config.php
public static $BOOTSTRAP_FULL_NOCLI

$BOOTSTRAP_NONE public static property

Do not include config.php at all
public static $BOOTSTRAP_NONE

$argumentNames protected property

protected array $argumentNames
return array

$arguments public property

public $arguments

$cwd public property

Current working directory
public string $cwd
return string

$defaults public property

Default global options
public array $defaults
return array

$expandedOptions public property

After expanding
public array $expandedOptions
return array

$finalOptions public property

Before expanding
public array $finalOptions
return array

$group protected property

protected $group

$maxArguments protected property

.
protected int $maxArguments
return integer

$minArguments protected property

How many arguments minimum are required.
protected int $minArguments
return integer

$mooshDir public property

moosh installation directory.
public string $mooshDir
return string

$name protected property

protected $name

$options public property

public $options

$parsedOptions protected property

protected OptionResult,GetOptionKit $parsedOptions
return GetOptionKit\OptionResult

$pluginInfo protected property

Possible information on plugin in a current directory.
protected array $pluginInfo
return array

$relativeDir public property

Directory relative to the current Moodle root dir.
public string $relativeDir
return string

$session protected property

Temporary session information.
protected array $session
return array

$spec public property

public OptionSpecCollection,GetOptionKit $spec
return GetOptionKit\OptionSpecCollection

$topDir public property

Top Moodle installation directory.
public string $topDir
return string

$verbose public property

public $verbose