PHP Class WP_CLI\Dispatcher\Subcommand

Inheritance: extends WP_CLI\Dispatcher\CompositeCommand
显示文件 Open project: wp-cli/wp-cli

Public Methods

Method Description
__construct ( $parent, $name, $docparser, $when_invoked )
can_have_subcommands ( ) : boolean Subcommands can't have subcommands because they represent code to be executed.
get_alias ( ) : string If an alias is set, grant access to it.
get_synopsis ( ) : string Get the synopsis string for this subcommand.
get_usage ( string $prefix ) : string Get the usage of the subcommand as a formatted string.
invoke ( array $args, array $assoc_args, $extra_args ) Invoke the subcommand with the supplied arguments.
set_synopsis ( $synopsis ) Set the synopsis string for this subcommand.
show_usage ( string $prefix = 'usage: ' ) Print the usage details to the end user.

Private Methods

Method Description
extract_synopsis ( string $longdesc ) : string Extract the synopsis from PHPdoc string.
prompt ( string $question, string $default ) : string | false Wrapper for CLI Tools' prompt() method.
prompt_args ( array $args, array $assoc_args ) : array Interactively prompt the user for input based on defined synopsis and passed arguments.
validate_args ( array $args, array $assoc_args, array $extra_args ) : array Validate the supplied arguments to the command.

Method Details

__construct() public method

public __construct ( $parent, $name, $docparser, $when_invoked )

can_have_subcommands() public method

Subcommands can't have subcommands because they represent code to be executed.
public can_have_subcommands ( ) : boolean
return boolean

get_alias() public method

Aliases permit subcommands to be instantiated with a secondary identity.
public get_alias ( ) : string
return string

get_synopsis() public method

A synopsis defines what runtime arguments are expected, useful to humans and argument validation.
public get_synopsis ( ) : string
return string

get_usage() public method

Get the usage of the subcommand as a formatted string.
public get_usage ( string $prefix ) : string
$prefix string
return string

invoke() public method

Given a --prompt argument, interactively request input from the end user.
public invoke ( array $args, array $assoc_args, $extra_args )
$args array
$assoc_args array

set_synopsis() public method

Set the synopsis string for this subcommand.
public set_synopsis ( $synopsis )

show_usage() public method

Print the usage details to the end user.
public show_usage ( string $prefix = 'usage: ' )
$prefix string