From c5aac68382e8504eb5504e55d9e8abd6b36d6c77 Mon Sep 17 00:00:00 2001 From: Valkeru Date: Wed, 15 Nov 2017 00:29:39 +0300 Subject: [PATCH] Fixes #15135: Automatic completion for help in bash and zsh --- contrib/completion/bash/yii | 4 +++- contrib/completion/zsh/_yii | 4 +++- framework/CHANGELOG.md | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/contrib/completion/bash/yii b/contrib/completion/bash/yii index 084325a..bc06b7a 100644 --- a/contrib/completion/bash/yii +++ b/contrib/completion/bash/yii @@ -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 @@ -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) diff --git a/contrib/completion/zsh/_yii b/contrib/completion/zsh/_yii index e85ebc3..01f4765 100644 --- a/contrib/completion/zsh/_yii +++ b/contrib/completion/zsh/_yii @@ -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 @@ -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 ;; diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index e5ba480..09a9fb0 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -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