Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK] Streamline auto completion script #261

Merged
merged 1 commit into from
Aug 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions Classes/Command/HelpCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ public function autoCompleteCommand($shell = 'bash', array $aliases = [])
$commandsOptions = [];
$commands = [];
foreach ($this->commands as $commandIdentifier => $command) {
$commandIdentifier = strtolower($commandIdentifier);
if ($commandIdentifier === 'help:autocomplete') {
$commandIdentifier = 'autocomplete';
} elseif ($commandIdentifier === 'help:help') {
$commandIdentifier = 'help';
}
$commands[] = $commandIdentifier;
$commandsDescriptions[$commandIdentifier] = $command->getShortDescription();
$commandsOptionsDescriptions[$commandIdentifier] = [];
Expand Down
12 changes: 12 additions & 0 deletions Classes/Mvc/Cli/CommandManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ protected function initialize()
}
}

/**
* @param string $commandIdentifier
* @return \TYPO3\CMS\Extbase\Mvc\Cli\Command
*/
public function getCommandByIdentifier($commandIdentifier)
{
if ($commandIdentifier === 'autocomplete') {
$commandIdentifier = 'extbase:help:autocomplete';
}
return parent::getCommandByIdentifier($commandIdentifier);
}

/**
* Make sure the object manager is set
*
Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/AutocompleteTemplates/cached.bash.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ _%%SCRIPT%%()
fi

# completing for a command
if [[ $cur == $com ]]; then
if [[ $cur == $com || $com == "help" ]]; then
coms="%%COMMANDS%%"

COMPREPLY=($(compgen -W "${coms}" -- ${cur}))
Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/AutocompleteTemplates/cached.zsh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ _%%SCRIPT%%()
if [[ ${cur} == --* ]]; then
state="option"
opts=(%%SHARED_OPTIONS%%)
elif [[ $cur == $com ]]; then
elif [[ $cur == $com || $com == "help" ]]; then
state="command"
coms=(%%COMMANDS%%)
fi
Expand Down