Skip to content

Commit

Permalink
In Zsh, do not autocomplete for disabled labels
Browse files Browse the repository at this point in the history
This resolves #54
  • Loading branch information
babab committed Mar 25, 2016
1 parent 91537cf commit 185ff45
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
13 changes: 13 additions & 0 deletions ChangeLog.rst
@@ -1,6 +1,19 @@
Change Log
----------

Development version (git/master) - to released
##############################################

Added
*****

* Automatic testing setup with Travis CI

Changed
*******

* In Zsh autocompletion, do not autocomplete for disabled labels

v0.3.0 - released March 18th, 2016
##################################

Expand Down
28 changes: 22 additions & 6 deletions zsh/_dispass
Expand Up @@ -3,14 +3,20 @@
local expl
local -a dispass_labels _dispass_commands

# TODO: split get_labels with and without --all switch and use appropriately
get_labels() {
get_labels_all() {
if [[ "$state" == labels ]]; then
dispass_labels=(${(f)"$(_call_program dispass_labels \
dispass list --all --script | awk '{ print $1 }' 2>/dev/null)"})
_wanted dispass_labels expl 'all labels' compadd -a dispass_labels
fi
}
get_labels_enabled() {
if [[ "$state" == labels ]]; then
dispass_labels=(${(f)"$(_call_program dispass_labels \
dispass list --script | awk '{ print $1 }' 2>/dev/null)"})
_wanted dispass_labels expl 'all labels' compadd -a dispass_labels
fi
}

_dispass_commands=(
'add:add a new label to labelfile'
Expand Down Expand Up @@ -54,7 +60,17 @@ case "$words[1]" in
'(-i --interactive -h --help -s --silent)-s[do not print success message]' \
'(-i --interactive -h --help -s --silent)--silent[do not print success message]' \
&& return 0 ;;
d* | e* | i* | u*)
d* | i* | u*)
_arguments \
'(-n --dry-run -s --silent)-h[show help information]' \
'(-n --dry-run -s --silent)--help[show help information]' \
'(-h --help -n --dry-run)-n[do not actually update label in labelfile]' \
'(-h --help -n --dry-run)--dry-run[do not actually update label in labelfile]' \
'(-h --help -s --silent)-s[do not print success message]' \
'(-h --help -s --silent)--silent[do not print success message]' \
'*:: :->labels' && return 0
get_labels_enabled ;;
e*)
_arguments \
'(-n --dry-run -s --silent)-h[show help information]' \
'(-n --dry-run -s --silent)--help[show help information]' \
Expand All @@ -63,7 +79,7 @@ case "$words[1]" in
'(-h --help -s --silent)-s[do not print success message]' \
'(-h --help -s --silent)--silent[do not print success message]' \
'*:: :->labels' && return 0
get_labels ;;
get_labels_all ;;
ge*)
_arguments \
'(-h --help)-h[show help information]' \
Expand All @@ -82,7 +98,7 @@ case "$words[1]" in
'(-h --help -o --output)--output[output passphrase(s) directly to stdout]' \
'(-h --help --silent)--silent[do not show a prompt when errors occur]' \
'*:: :->labels' && return 0
get_labels ;;
get_labels_enabled ;;
gu*)
_arguments \
'(-h --help)-h[show help information]' \
Expand Down Expand Up @@ -110,7 +126,7 @@ case "$words[1]" in
'(-i --interactive -h --help -s --silent)-s[do not print success message]' \
'(-i --interactive -h --help -s --silent)--silent[do not print success message]' \
'*:: :->labels' && return 0
get_labels ;;
get_labels_all ;;
v*)
return 0
esac
Expand Down

0 comments on commit 185ff45

Please sign in to comment.