spm

Personal fork of spm (simple password manager)
git clone git@getsh.org:spm.git
Log | Files | Refs | README | LICENSE

commit e0c3ae3136bc2f4702eb001de5aac8e7ddcea777
parent 296a9b09e978074fd073ca3b9b76a957c1b9c238
Author: Sören Tempel <soeren+git@soeren-tempel.net>
Date:   Wed, 18 Feb 2015 17:52:50 +0100

Use a case

Diffstat:
Mcontrib/bash_completion | 18+++++++++++-------
Mcontrib/zsh_completion | 26++++++++++++++------------
2 files changed, 25 insertions(+), 19 deletions(-)

diff --git a/contrib/bash_completion b/contrib/bash_completion @@ -17,13 +17,17 @@ _tpm() { local cur="${COMP_WORDS[COMP_CWORD]}" local cmd="${COMP_WORDS[1]}" - if [[ "${cmd}" = "insert" ]]; then - _tpm_complete_entries - elif [[ "${cmd}" = "show" ]]; then - _tpm_complete_entries -type f - else - COMPREPLY=($(compgen -W "insert show" -- ${cur})) - fi + case "${cmd}" + "insert") + _tpm_complete_entries + ;; + "show") + _tpm_complete_entries -type f + ;; + *) + COMPREPLY=($(compgen -W "insert show" -- ${cur})) + ;; + esac } _tpm_complete_entries() { diff --git a/contrib/zsh_completion b/contrib/zsh_completion @@ -16,19 +16,21 @@ _tpm() { local cmd=${words[2]} - if [[ "${cmd}" = "insert" ]]; then - _tpm_complete_entries - elif [[ "${cmd}" = "show" ]]; then - _tpm_complete_entries -type f - else - local -a subcommands - subcommands=( - "show:Show a password for a specified entry" - "insert:Insert a new password entry" - ) - _describe -t commands "tpm" subcommands - fi + case "${cmd}" + "insert") + _tpm_complete_entries + ;; + "show") + _tpm_complete_entries -type f + *) + local subcommands=( + "show:Show a password for a specified entry" + "insert:Insert a new password entry" + ) + + _describe -t commands "tpm" subcommands + esac } _tpm_complete_entries() {