Skip to content

Commit

Permalink
Fixes #15135: Automatic completion for help in bash and zsh
Browse files Browse the repository at this point in the history
  • Loading branch information
Valkeru authored and samdark committed Nov 14, 2017
1 parent 10e7b1b commit c5aac68
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion contrib/completion/bash/yii
Expand Up @@ -15,6 +15,7 @@ _yii()
local cur opts yii command
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
yii="${COMP_WORDS[0]}"

# exit if ./yii does not exist
Expand All @@ -31,9 +32,10 @@ _yii()
[[ $cur == $command ]] && state="command"
[[ $cur != $command ]] && state="option"
[[ $cur = *=* ]] && state="value"
[[ $prev == "help" ]] && state="help"

case $state in
command)
command|help)
# complete command/route if not given
# fetch available commands from ./yii help/list command
opts=$($yii help/list 2> /dev/null)
Expand Down
4 changes: 3 additions & 1 deletion contrib/completion/zsh/_yii
Expand Up @@ -3,6 +3,7 @@
_yii() {
local state command lastArgument commands options executive
lastArgument=${words[${#words[@]}]}
prevArgument=${words[${#words[@]}-1]}
executive=$words[1]

# lookup for command
Expand All @@ -16,9 +17,10 @@ _yii() {

[[ $lastArgument == $command ]] && state="command"
[[ $lastArgument != $command ]] && state="option"
[[ $prevArgument == "help" ]] && state="help"

case $state in
command)
command|help)
commands=("${(@f)$(${executive} help/list 2>/dev/null)}")
_describe 'command' commands
;;
Expand Down
1 change: 1 addition & 0 deletions framework/CHANGELOG.md
Expand Up @@ -5,6 +5,7 @@ Yii Framework 2 Change Log
------------------------

- Bug #14276: Fixed I18N format with dotted parameters (developeruz)
- Enh #15135: Automatic completion for help in bash and zsh (Valkeru)


2.0.13.1 November 14, 2017
Expand Down

0 comments on commit c5aac68

Please sign in to comment.