Debian Codegraph @

bash-completion/dput.bash

raw
1 # bash-completion/dput.bash
2 # Programmable Bash command completion for ‘dput’ command.
3 # See the Bash manual “Programmable Completion” section.
4 #
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.
8
9 _have dput &&
10 _dput () {
11 COMPREPLY=()
12
13 local cur="${COMP_WORDS[COMP_CWORD]}"
14 local prev="${COMP_WORDS[COMP_CWORD-1]}"
15
16 local -a options=(
17 -D --dinstall
18 -H --host-list
19 -P --passive
20 -U --no-upload-log
21 -V --check-version
22 -c --config
23 -d --debug
24 -e --delayed
25 -f --force
26 -h --help
27 -l --lintian
28 -o --check-only
29 -p --print
30 -s --simulate
31 -u --unchecked
32 -v --version
33 )
34
35 local -a config_files=(
36 "${XDG_CONFIG_HOME:-$HOME/.config}/dput/dput.cf"
37 "$HOME/.dput.cf"
38 "/etc/dput.cf"
39 )
40 local -a hosts
41 readarray -t hosts < <( {
42 grep --no-filename "^\[.*\]" "${config_files[@]}" \
43 2> /dev/null \
44 | tr --delete '[]' || /bin/true
45 } | grep --invert-match '^DEFAULT$' | sort --unique )
46
47 case "$prev" in
48 -e|--delayed)
49 local -a delayed_values=( {0..15} )
50 readarray -t COMPREPLY < <(
51 compgen -W "${delayed_values[*]}" -- "$cur"
52 )
53 ;;
54 -c|--config)
55 readarray -t COMPREPLY < <( compgen -G "${cur}*" )
56 compopt -o filenames
57 compopt -o plusdirs
58 ;;
59 *)
60 readarray -t COMPREPLY < <(
61 compgen -G "${cur}*.changes"
62 compgen -G "${cur}*.dsc"
63 compgen -W "${hosts[*]}" -- "$cur"
64 compgen -W "${options[*]}" -- "$cur"
65 )
66 compopt -o filenames
67 compopt -o plusdirs
68 ;;
69 esac
70
71 return 0
72
73 } && complete -F _dput dput
74
75
76 # Copyright © 2015–2026 Ben Finney <[email protected]>
77 # Copyright © 2002 Roland Mas <[email protected]>
78 #
79 # This is free software: you may copy, modify, and/or distribute this work
80 # under the terms of the GNU General Public License as published by the
81 # Free Software Foundation; version 3 of that license or any later version.
82 # No warranty expressed or implied. See the file ‘LICENSE.GPL-3’ for details.
83
84 # Local variables:
85 # coding: utf-8
86 # mode: shell-script
87 # End:
88 # vim: fileencoding=utf-8 filetype=bash :