Debian Codegraph @

debian/towncrier.bash-completion

raw
1 # towncrier.bash-completion
2 # Part of Debian ‘towncrier’ package.
3 #
4 # Programmable Bash command completion for the ‘towncrier’ command.
5 # See the Bash manual “Programmable Completion” section.
6 #
7 # This is free software, and you are welcome to redistribute it under
8 # certain conditions; see the end of this file for copyright
9 # information, grant of license, and disclaimer of warranty.
10
11 _have towncrier &&
12 _towncrier_completion () {
13 COMPREPLY=()
14
15 local cur="${COMP_WORDS[COMP_CWORD]}"
16 local prev="${COMP_WORDS[COMP_CWORD-1]}"
17
18 local -a options=(
19 -h --help -v --version
20 --config
21 --dir
22 )
23 local -a sub_commands=(
24 build
25 create
26 check
27 )
28
29 case "${prev}" in
30 --config)
31 readarray -t COMPREPLY < <( compgen -G "${cur}*" )
32 compopt -o filenames
33 compopt -o plusdirs
34 ;;
35 --dir)
36 readarray -t COMPREPLY < <( compgen -G "${cur}*" )
37 compopt -o dirnames
38 ;;
39 build)
40 options=(
41 --name --version --date
42 --draft --yes --keep
43 )
44 readarray -t COMPREPLY < <( compgen -W "${options[*]}" -- "$cur" )
45 ;;
46 --name)
47 # We have no useful completion for an arbitrary project name.
48 ;;
49 --version)
50 # We have no useful completion for an arbitrary version string.
51 ;;
52 --date)
53 # We have no useful completion for an arbitrary date.
54 ;;
55 create)
56 options=(
57 --content
58 --edit --no-edit
59 )
60 readarray -t COMPREPLY < <(
61 compgen -W "${options[*]}" -- "$cur"
62 compgen -G "${cur}*"
63 )
64 compopt -o filenames
65 compopt -o plusdirs
66 ;;
67 --content)
68 # We have no useful completion for an arbitrary text message.
69 ;;
70 --edit|--no-edit)
71 readarray -t COMPREPLY < <( compgen -G "${cur}*" )
72 compopt -o filenames
73 compopt -o plusdirs
74 ;;
75 check)
76 options=( --compare-with )
77 readarray -t COMPREPLY < <( compgen -W "${options[*]}" -- "$cur" )
78 # We have no useful completion for an arbitrary hash value.
79 ;;
80 --compare-with)
81 # We have no useful completion for an arbitrary hash value.
82 ;;
83 -v|--valid-chars)
84 # We have no useful completion for a literal regex argument.
85 ;;
86 -n|--numwords|--min|--max)
87 # We have no useful completion for a numeric argument.
88 ;;
89 -c|--count)
90 # We have no useful completion for a numeric argument.
91 ;;
92 *)
93 readarray -t COMPREPLY < <(
94 compgen -W "${options[*]}" -- "$cur"
95 compgen -W "${sub_commands[*]}" -- "$cur"
96 )
97 ;;
98 esac
99
100 return 0
101
102 } && complete -F _towncrier_completion towncrier
103
104
105 # Copyright © 2015–2025 Ben Finney <[email protected]>
106 #
107 # This is free software: you may copy, modify, and/or distribute this work
108 # under the terms of the GNU General Public License as published by the
109 # Free Software Foundation; version 3 of that license or any later version.
110 # No warranty expressed or implied. See the file ‘LICENSE.GPL-3’ for details.
111
112 # Local variables:
113 # coding: utf-8
114 # mode: shell-script
115 # End:
116 # vim: fileencoding=utf-8 filetype=bash :