Debian Codegraph @

src/ietf2bibtex.bash-completion

raw
1 # shellcheck shell=bash
2 # ==========================================================================
3 # ____ _ _ _____ __ ______
4 # | __ )(_) |_|_ _|__\ \/ / ___|___ _ ____ __
5 # | _ \| | '_ \| |/ _ \ / | / _ \| '_ \ \ / /
6 # | |_) | | |_) | | __// \ |__| (_) | | | \ V /
7 # |____/|_|_.__/|_|\___/_/\_\____\___/|_| |_|\_/
8 #
9 # --- BibTeX Converter ---
10 # https://www.nntb.no/~dreibh/bibtexconv/
11 # ==========================================================================
12 #
13 # IETF2BibTeX
14 # Copyright (C) 2014-2026 by Thomas Dreibholz
15 #
16 # This program is free software: you can redistribute it and/or modify
17 # it under the terms of the GNU General Public License as published by
18 # the Free Software Foundation, either version 3 of the License, or
19 # (at your option) any later version.
20 #
21 # This program is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU General Public License for more details.
25 #
26 # You should have received a copy of the GNU General Public License
27 # along with this program. If not, see <http://www.gnu.org/licenses/>.
28 #
29 # Contact: [email protected]
30
31
32 # ###### Bash completion for ietf2bibtex #####################################
33 _ietf2bibtex()
34 {
35 # Based on: https://www.benningtons.net/index.php/bash-completion/
36 local cur prev words cword
37 if type -t _comp_initialize >/dev/null; then
38 _comp_initialize -n = || return
39 elif type -t _init_completion >/dev/null; then
40 _init_completion -n = || return
41 else
42 # Manual initialization for older bash completion versions:
43 COMPREPLY=()
44 cur="${COMP_WORDS[COMP_CWORD]}"
45 # shellcheck disable=SC2034
46 prev="${COMP_WORDS[COMP_CWORD-1]}"
47 # shellcheck disable=SC2034,SC2124
48 words="${COMP_WORDS[@]}"
49 # shellcheck disable=SC2034
50 cword="${COMP_CWORD}"
51 fi
52
53 # ====== Parameters ======================================================
54 case "${prev}" in
55 # ====== Generic file =============================================
56 --authors-fix-file=)
57 _filedir
58 return
59 ;;
60 esac
61
62 # ====== All options =====================================================
63 # Simple options without parameter(s)
64 local opts1="
65 --quiet
66 --verbose
67 --no-authors-fix-file
68 "
69 # Options with "=" and parameter(s)
70 local opts2="
71 --authors-fix-file
72 "
73 # shellcheck disable=SC2207
74 COMPREPLY=( $( compgen -W "${opts1}" -- "${cur}" )
75 $( compgen -W "${opts2}" -S "=" -- "${cur}" ) )
76 [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
77
78 return 0
79 }
80
81 complete -F _ietf2bibtex ietf2bibtex