PHP Class Stecman\Component\Symfony\Console\BashCompletion\CompletionHandler

Mostrar archivo Open project: stecman/symfony-console-completion Class Usage Examples

Protected Properties

Property Type Description
$application Symfony\Component\Console\Application Application to complete for
$command Symfony\Component\Console\Command\Command
$context CompletionContext
$helpers Stecman\Component\Symfony\Console\BashCompletion\Completion\CompletionInterface[] Array of completion helpers.

Public Methods

Method Description
__construct ( Application $application, CompletionContext $context = null )
addHandler ( Stecman\Component\Symfony\Console\BashCompletion\Completion\CompletionInterface $helper )
addHandlers ( array $array )
getContext ( ) : CompletionContext
getInput ( ) : Symfony\Component\Console\Input\ArrayInput Get an InputInterface representation of the completion context
runCompletion ( ) : string[] Do the actual completion, returning an array of strings to provide to the parent shell's completion system
setContext ( CompletionContext $context )

Protected Methods

Method Description
completeForCommandArguments ( ) : array | false Attempt to complete the current word as a command argument value
completeForCommandName ( ) : array | false Attempt to complete the current word as a command name
completeForOptionShortcutValues ( ) : array | false Attempt to complete the current word as the value of an option shortcut
completeForOptionShortcuts ( ) : array | false Attempt to complete the current word as an option shortcut.
completeForOptionValues ( ) : array | false Attemp to complete the current word as the value of a long-form option
completeForOptions ( ) : array | false Attempt to complete the current word as a long-form option (--my-option)
completeOption ( Symfony\Component\Console\Input\InputOption $option ) : array | false Complete the value for the given option if a value completion is availble
filterResults ( array $array ) : string[] Filter out results that don't match the current word on the command line
getAllOptions ( ) : Symfony\Component\Console\Input\InputOption[] Get the combined options of the application and entered command
getCompletionHelper ( string $name, string $type ) : Stecman\Component\Symfony\Console\BashCompletion\Completion\CompletionInterface | null Find a CompletionInterface that matches the current command, target name, and target type
getOptionWordsWithValues ( ) : string[] Build a list of option words/flags that will have a value after them Options are returned in the format they appear as on the command line.
mapArgumentsToWords ( Symfony\Component\Console\Input\InputArgument[] $argumentDefinitions ) : array Step through the command line to determine which word positions represent which argument values

Method Details

__construct() public method

public __construct ( Application $application, CompletionContext $context = null )
$application Symfony\Component\Console\Application
$context CompletionContext

addHandler() public method

public addHandler ( Stecman\Component\Symfony\Console\BashCompletion\Completion\CompletionInterface $helper )
$helper Stecman\Component\Symfony\Console\BashCompletion\Completion\CompletionInterface

addHandlers() public method

public addHandlers ( array $array )
$array array

completeForCommandArguments() protected method

Attempt to complete the current word as a command argument value
See also: Symfony\Component\Console\Input\InputArgument
protected completeForCommandArguments ( ) : array | false
return array | false

completeForCommandName() protected method

Attempt to complete the current word as a command name
protected completeForCommandName ( ) : array | false
return array | false

completeForOptionShortcutValues() protected method

Attempt to complete the current word as the value of an option shortcut
protected completeForOptionShortcutValues ( ) : array | false
return array | false

completeForOptionShortcuts() protected method

If the shortcut exists it will be completed, but a list of possible shortcuts is never returned for completion.
protected completeForOptionShortcuts ( ) : array | false
return array | false

completeForOptionValues() protected method

Attemp to complete the current word as the value of a long-form option
protected completeForOptionValues ( ) : array | false
return array | false

completeForOptions() protected method

Attempt to complete the current word as a long-form option (--my-option)
protected completeForOptions ( ) : array | false
return array | false

completeOption() protected method

Complete the value for the given option if a value completion is availble
protected completeOption ( Symfony\Component\Console\Input\InputOption $option ) : array | false
$option Symfony\Component\Console\Input\InputOption
return array | false

filterResults() protected method

Filter out results that don't match the current word on the command line
protected filterResults ( array $array ) : string[]
$array array
return string[]

getAllOptions() protected method

Get the combined options of the application and entered command
protected getAllOptions ( ) : Symfony\Component\Console\Input\InputOption[]
return Symfony\Component\Console\Input\InputOption[]

getCompletionHelper() protected method

Find a CompletionInterface that matches the current command, target name, and target type
protected getCompletionHelper ( string $name, string $type ) : Stecman\Component\Symfony\Console\BashCompletion\Completion\CompletionInterface | null
$name string
$type string
return Stecman\Component\Symfony\Console\BashCompletion\Completion\CompletionInterface | null

getContext() public method

public getContext ( ) : CompletionContext
return CompletionContext

getInput() public method

Get an InputInterface representation of the completion context
public getInput ( ) : Symfony\Component\Console\Input\ArrayInput
return Symfony\Component\Console\Input\ArrayInput

getOptionWordsWithValues() protected method

Build a list of option words/flags that will have a value after them Options are returned in the format they appear as on the command line.
protected getOptionWordsWithValues ( ) : string[]
return string[] - eg. ['--myoption', '-m', ... ]

mapArgumentsToWords() protected method

The word indexes of argument values are found by eliminating words that are known to not be arguments (options, option values, and command names). Any word that doesn't match for elimination is assumed to be an argument value,
protected mapArgumentsToWords ( Symfony\Component\Console\Input\InputArgument[] $argumentDefinitions ) : array
$argumentDefinitions Symfony\Component\Console\Input\InputArgument[]
return array as [argument name => word index on command line]

runCompletion() public method

Do the actual completion, returning an array of strings to provide to the parent shell's completion system
public runCompletion ( ) : string[]
return string[]

setContext() public method

public setContext ( CompletionContext $context )
$context CompletionContext

Property Details

$application protected_oe property

Application to complete for
protected Application,Symfony\Component\Console $application
return Symfony\Component\Console\Application

$command protected_oe property

protected Command,Symfony\Component\Console\Command $command
return Symfony\Component\Console\Command\Command

$context protected_oe property

protected CompletionContext,Stecman\Component\Symfony\Console\BashCompletion $context
return CompletionContext

$helpers protected_oe property

Array of completion helpers.
protected CompletionInterface[],Stecman\Component\Symfony\Console\BashCompletion\Completion $helpers
return Stecman\Component\Symfony\Console\BashCompletion\Completion\CompletionInterface[]