An input specialized for shell completion.
This input allows unfinished option names or values and exposes what kind of completion is expected.
- Full name:
\Symfony\Component\Console\Completion\CompletionInput
- Parent class:
\Symfony\Component\Console\Input\ArgvInput
- This class is marked as final and can't be subclassed
- This class is a Final class
Constant | Visibility | Type | Value |
---|---|---|---|
TYPE_ARGUMENT_VALUE |
public | 'argument_value' | |
TYPE_OPTION_VALUE |
public | 'option_value' | |
TYPE_OPTION_NAME |
public | 'option_name' | |
TYPE_NONE |
public | 'none' |
private $tokens
private $currentIndex
private $completionType
private $completionName
private $completionValue
Converts a terminal string into tokens.
public static fromString(string $inputStr, int $currentIndex): self
This is required for shell completions without COMP_WORDS support.
- This method is static.
Parameters:
Parameter | Type | Description |
---|---|---|
$inputStr |
string | |
$currentIndex |
int |
Create an input based on an COMP_WORDS token list.
public static fromTokens(string[] $tokens, $currentIndex): self
- This method is static.
Parameters:
Parameter | Type | Description |
---|---|---|
$tokens |
string[] | the set of split tokens (e.g. COMP_WORDS or argv) |
$currentIndex |
**** | the index of the cursor (e.g. COMP_CWORD) |
{@inheritdoc}
public bind(\Symfony\Component\Console\Input\InputDefinition $definition): void
Parameters:
Parameter | Type | Description |
---|---|---|
$definition |
\Symfony\Component\Console\Input\InputDefinition |
Returns the type of completion required.
public getCompletionType(): string
TYPE_ARGUMENT_VALUE when completing the value of an input argument TYPE_OPTION_VALUE when completing the value of an input option TYPE_OPTION_NAME when completing the name of an input option TYPE_NONE when nothing should be completed
Return Value:
One of self::TYPE_* constants. TYPE_OPTION_NAME and TYPE_NONE are already implemented by the Console component
The name of the input option or argument when completing a value.
public getCompletionName(): string|null
Return Value:
returns null when completing an option name
The value already typed by the user (or empty string).
public getCompletionValue(): string
public mustSuggestOptionValuesFor(string $optionName): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$optionName |
string |
public mustSuggestArgumentValuesFor(string $argumentName): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$argumentName |
string |
protected parseToken(string $token, bool $parseOptions): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$token |
string | |
$parseOptions |
bool |
private getOptionFromToken(string $optionToken): ?\Symfony\Component\Console\Input\InputOption
Parameters:
Parameter | Type | Description |
---|---|---|
$optionToken |
string |
The token of the cursor, or the last token if the cursor is at the end of the input.
private getRelevantToken(): string
Whether the cursor is "free" (i.e. at the end of the input preceded by a space).
private isCursorFree(): bool
Returns a stringified representation of the args passed to the command.
public __toString(): string
public __construct(\Symfony\Component\Console\Input\InputDefinition $definition = null): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$definition |
\Symfony\Component\Console\Input\InputDefinition |
protected setTokens(array $tokens): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$tokens |
array |
Processes command line arguments.
protected parse(): mixed
- This method is abstract.
protected parseToken(string $token, bool $parseOptions): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$token |
string | |
$parseOptions |
bool |
Parses a short option.
private parseShortOption(string $token): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$token |
string |
Parses a short option set.
private parseShortOptionSet(string $name): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
string |
Parses a long option.
private parseLongOption(string $token): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$token |
string |
Parses an argument.
private parseArgument(string $token): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$token |
string |
Adds a short option value.
private addShortOption(string $shortcut, mixed $value): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$shortcut |
string | |
$value |
mixed |
Adds a long option value.
private addLongOption(string $name, mixed $value): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
string | |
$value |
mixed |
{@inheritdoc}
public getFirstArgument(): mixed
{@inheritdoc}
public hasParameterOption(mixed $values, bool $onlyParams = false): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$values |
mixed | |
$onlyParams |
bool |
{@inheritdoc}
public getParameterOption(mixed $values, mixed $default = false, bool $onlyParams = false): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$values |
mixed | |
$default |
mixed | |
$onlyParams |
bool |
Returns a stringified representation of the args passed to the command.
public __toString(): string
Binds the current Input instance with the given arguments and options.
public bind(\Symfony\Component\Console\Input\InputDefinition $definition): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$definition |
\Symfony\Component\Console\Input\InputDefinition |
Validates the input.
public validate(): mixed
Is this input means interactive?
public isInteractive(): bool
Sets the input interactivity.
public setInteractive(bool $interactive): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$interactive |
bool |
Returns all the given arguments merged with the default values.
public getArguments(): (string|bool|int|float|array|null)[]
Returns the argument value for a given argument name.
public getArgument(string $name): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
string |
Sets an argument value by name.
public setArgument(string $name, mixed $value): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
string | |
$value |
mixed | The argument value |
Returns true if an InputArgument object exists by name or position.
public hasArgument(string $name): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
string |
Returns all the given options merged with the default values.
public getOptions(): (string|bool|int|float|array|null)[]
Returns the option value for a given option name.
public getOption(string $name): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
string |
Sets an option value by name.
public setOption(string $name, mixed $value): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
string | |
$value |
mixed | The option value |
Returns true if an InputOption object exists by name.
public hasOption(string $name): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
string |
Escapes a token through escapeshellarg if it contains unsafe chars.
public escapeToken(string $token): string
Parameters:
Parameter | Type | Description |
---|---|---|
$token |
string |
Sets the input stream to read from when interacting with the user.
public setStream(mixed $stream): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$stream |
mixed | The input stream |
Returns the input stream.
public getStream(): resource|null