Define cases with the conventional order for options spellings.
[dput.git] / bash-completion / dput.bash
blob8a6ad91412ce1c415172007302cbf9ae3be22649
1 # bash-completion/dput.bash
2 # Programmable Bash command completion for ‘dput’ command.
3 # See the Bash manual “Programmable Completion” section.
5 # This is free software, and you are welcome to redistribute it under
6 # certain conditions; see the end of this file for copyright
7 # information, grant of license, and disclaimer of warranty.
9 _have dput &&
10 _dput () {
11 COMPREPLY=()
13 local cur="${COMP_WORDS[COMP_CWORD]}"
14 local prev="${COMP_WORDS[COMP_CWORD-1]}"
16 local options="
17 -c --config -d --debug -D --dinstall -f --force -h --help
18 -H --host-list -l --lintian -o --check-only -p --print
19 -P --passive -s --simulate -u --unchecked -e --delayed
20 -v --version -V --check-version
23 local hosts=$( {
24 grep "^\[.*\]" $HOME/.dput.cf 2> /dev/null | tr -d [] || /bin/true
25 grep "^\[.*\]" /etc/dput.cf 2> /dev/null | tr -d [] || /bin/true
26 } | grep -v '^DEFAULT$' | sort -u)
28 case "$prev" in
29 -e|--delayed)
30 local delayed_options='0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15'
31 COMPREPLY=( $( compgen -W "$delayed_options" | grep ^$cur ) )
33 -c|--config)
34 COMPREPLY=( $( compgen -o filenames -G "$cur*" ) )
37 COMPREPLY=( $(
38 compgen -G "${cur}*.changes"
39 compgen -G "${cur}*.asc"
40 compgen -G "${cur}*.sig"
41 compgen -W "$hosts" | grep "^$cur"
42 compgen -W "$options" | grep "^$cur"
43 ) )
45 esac
47 return 0
49 } && complete -F _dput -o filenames -o plusdirs dput
52 # Copyright © 2015–2016 Ben Finney <bignose@debian.org>
53 # Copyright © 2002 Roland Mas <lolando@debian.org>
55 # This is free software: you may copy, modify, and/or distribute this work
56 # under the terms of the GNU General Public License as published by the
57 # Free Software Foundation; version 3 of that license or any later version.
58 # No warranty expressed or implied. See the file ‘LICENSE.GPL-3’ for details.
60 # Local variables:
61 # coding: utf-8
62 # mode: sh
63 # End:
64 # vim: fileencoding=utf-8 filetype=sh :