diff options
author | Guido Günther <agx@sigxcpu.org> | 2015-05-04 09:06:45 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2015-05-04 09:14:32 +0200 |
commit | 15187ba6f1794629d6550dada242f0d11ad605e1 (patch) | |
tree | 26df22d993d4027bf57f73680f9f504927b60d7c | |
parent | 451ec187fbf9c3c6becb17430cbb930bbc9bce51 (diff) |
bash-completion: Avoid passing around default options
All commands except for 'buildackage' share the same option names. Don't
pass them around needlesly. Since these names only indicate the type
of completion it doesn't matter if we have them for commands that don't
support them.
-rw-r--r-- | debian/git-buildpackage.bash-completion | 53 |
1 files changed, 12 insertions, 41 deletions
diff --git a/debian/git-buildpackage.bash-completion b/debian/git-buildpackage.bash-completion index 50c9e1b8..e9b3c897 100644 --- a/debian/git-buildpackage.bash-completion +++ b/debian/git-buildpackage.bash-completion @@ -38,9 +38,10 @@ _gbp_comp () local cur="${COMP_WORDS[COMP_CWORD]}" local prev="${COMP_WORDS[COMP_CWORD - 1]}" local options=$1 - local branch_opts=$2 - local tag_opts=$3 - local tristate_opts=$4 + local branch_opts=${2:-"--debian-branch\= --upstream-branch\="} + local tag_opts=${3:-"--debian-tag\= --upstream-tag\="} + local tristate_opts=${4:-"--color\="} + local cbdist_opts=${5:-"--git-dist\="} # COMPREPLY considers '=' as a word. For $prev we prefer the word before the actual "=" if [[ "$prev" == "=" ]]; then @@ -105,7 +106,6 @@ _gbp-buildpackage() local branch_opts="--git-debian-branch\= --git-upstream-branch\= --git-upstream-tree\=" local tag_opts="--git-debian-tag\= --git-upstream-tag\=" local tristate_opts="--git-color\= --git-notify\=" - local cbdist_opts="--git-dist\=" _gbp_comp "$options" "$branch_opts" "$tag_opts" "$tristate_opts" \ "$cbdist_opts" @@ -114,79 +114,50 @@ _gbp-buildpackage() _gbp-dch () { local options=$(_gbp_options dch) - local branch_opts="--debian-branch\=" - local tag_opts="--debian-tag\= --upstream-tag\=" - local tristate_opts="--color\=" - - _gbp_comp "$options" "$branch_opts" "$tag_opts" "$tristate_opts" + _gbp_comp "$options" } _gbp-import-orig () { local options=$(_gbp_options import-orig) - local branch_opts="--debian-branch\= --upstream-branch\=" - local tag_opts="--debian-tag\= --upstream-tag\=" - local tristate_opts="--color\=" - - _gbp_comp "$options" "$branch_opts" "$tag_opts" "$tristate_opts" + _gbp_comp "$options" } _gbp-import-dsc () { local options=$(_gbp_options import-dsc) - local branch_opts="--debian-branch\= --upstream-branch\=" - local tag_opts="--debian-tag\= --upstream-tag\=" - local tristate_opts="--color\=" - - _gbp_comp "$options" "$branch_opts" "$tag_opts" "$tristate_opts" + _gbp_comp "$options" } _gbp-import-dscs () { local options="$(_gbp_options import-dscs) $(_gbp_options import-dsc)" - local branch_opts="--debian-branch\= --upstream-branch\=" - local tag_opts="--debian-tag\= --upstream-tag\=" - local tristate_opts="--color\=" - - _gbp_comp "$options" "$branch_opts" "$tag_opts" "$tristate_opts" + _gbp_comp "$options" } _gbp-pq () { local options=$(_gbp_options pq) options="$options export import rebase drop apply switch" - local tristate_opts="--color\=" - - _gbp_comp "$options" "" "" "$tristate_opts" + _gbp_comp "$options" } _gbp-pull () { local options=$(_gbp_options pull) - local branch_opts="--debian-branch\= --upstream-branch\=" - local tag_opts="--debian-tag\= --upstream-tag\=" - local tristate_opts="--color\=" - - _gbp_comp "$options" "$branch_opts" "$tag_opts" "$tristate_opts" + _gbp_comp "$options" } _gbp-clone () { local options=$(_gbp_options clone) - local branch_opts="--debian-branch\= --upstream-branch\=" - local tag_opts="--debian-tag\= --upstream-tag\=" - local tristate_opts="--color\=" - - _gbp_comp "$options" "$branch_opts" "$tag_opts" "$tristate_opts" + _gbp_comp "$options" } _gbp-create-remote-repo () { local options=$(_gbp_options create-remote-repo) - local branch_opts="--debian-branch\= --upstream-branch\=" - local tristate_opts="--color\=" - - _gbp_comp "$options" "$branch_opts" "" "$tristate_opts" + _gbp_comp "$options" } have gbp && |