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

Represents the current state of the command line that is being completed
Afficher le fichier Open project: stecman/symfony-console-completion Class Usage Examples

Protected Properties

Свойство Type Description
$charIndex integer If the current cursor position is at the end of the current command, the value of this variable is equal to the length of $this->commandLine Bash equivalent: COMP_POINT
$commandLine string Bash equivalent: COMP_LINE
$wordBreaks string Bash equivalent: COMP_WORDBREAKS
$wordIndex integer | null This is not set until $this->splitCommand() is called. Bash equivalent: COMP_CWORD
$words array | null This is not set until $this->splitCommand() is called, when it is populated by $commandLine exploded by $wordBreaks Bash equivalent: COMP_WORDS

Méthodes publiques

Méthode Description
getCharIndex ( ) : integer Get the character index of the user's cursor on the command line
getCommandLine ( ) : string Return the current command line verbatim as a string
getCurrentWord ( ) : string Return the word from the command line that the cursor is currently in
getWordAtIndex ( integer $index ) : string Return a word by index from the command line
getWordIndex ( ) : integer Get the index of the word the cursor is currently in
getWords ( ) : array Get the contents of the command line, exploded into words based on the configured word break characters
setCharIndex ( integer $index ) Set the cursor position as a character index relative to the start of the command line
setCommandLine ( string $commandLine ) Set the whole contents of the command line as a string
setWordBreaks ( string $charList ) Set characters to use as split points when breaking the command line into words

Méthodes protégées

Méthode Description
reset ( ) Reset the computed words so that $this->splitWords is forced to run again
splitCommand ( ) : string[] Split the command line into words using the configured word break characters

Method Details

getCharIndex() public méthode

This is in the context of the full command line string, so includes word break characters. Note that some shells can only provide an approximation for character index. Under ZSH for example, this will always be the character at the start of the current word.
public getCharIndex ( ) : integer
Résultat integer

getCommandLine() public méthode

Return the current command line verbatim as a string
public getCommandLine ( ) : string
Résultat string

getCurrentWord() public méthode

Most of the time this will be a partial word. If the cursor has a space before it, this will return an empty string, indicating a new word.
public getCurrentWord ( ) : string
Résultat string

getWordAtIndex() public méthode

Return a word by index from the command line
public getWordAtIndex ( integer $index ) : string
$index integer
Résultat string

getWordIndex() public méthode

Get the index of the word the cursor is currently in
public getWordIndex ( ) : integer
Résultat integer

getWords() public méthode

Get the contents of the command line, exploded into words based on the configured word break characters
public getWords ( ) : array
Résultat array

reset() protected méthode

Reset the computed words so that $this->splitWords is forced to run again
protected reset ( )

setCharIndex() public méthode

Set the cursor position as a character index relative to the start of the command line
public setCharIndex ( integer $index )
$index integer

setCommandLine() public méthode

Set the whole contents of the command line as a string
public setCommandLine ( string $commandLine )
$commandLine string

setWordBreaks() public méthode

This defaults to a sane value based on BASH's word break characters and shouldn't need to be changed unless your completions contain the default word break characters.
See also: wordBreaks
public setWordBreaks ( string $charList )
$charList string - a single string containing all of the characters to break words on

splitCommand() protected méthode

Split the command line into words using the configured word break characters
protected splitCommand ( ) : string[]
Résultat string[]

Property Details

$charIndex protected_oe property

If the current cursor position is at the end of the current command, the value of this variable is equal to the length of $this->commandLine Bash equivalent: COMP_POINT
protected int $charIndex
Résultat integer

$commandLine protected_oe property

Bash equivalent: COMP_LINE
protected string $commandLine
Résultat string

$wordBreaks protected_oe property

Bash equivalent: COMP_WORDBREAKS
protected string $wordBreaks
Résultat string

$wordIndex protected_oe property

This is not set until $this->splitCommand() is called. Bash equivalent: COMP_CWORD
protected int|null $wordIndex
Résultat integer | null

$words protected_oe property

This is not set until $this->splitCommand() is called, when it is populated by $commandLine exploded by $wordBreaks Bash equivalent: COMP_WORDS
protected array|null $words
Résultat array | null