]> git.ipfire.org Git - thirdparty/systemd.git/blame - shell-completion/bash/systemd-dissect
hwdb: Add mapping for Xiaomi Mipad 2 bottom bezel capacitive buttons
[thirdparty/systemd.git] / shell-completion / bash / systemd-dissect
CommitLineData
f8457290 1# shellcheck shell=bash
808ec9df
AAF
2# systemd-dissect(1) completion -*- shell-script -*-
3# SPDX-License-Identifier: LGPL-2.1-or-later
4#
5# This file is part of systemd.
6#
7# systemd is free software; you can redistribute it and/or modify it
8# under the terms of the GNU Lesser General Public License as published by
9# the Free Software Foundation; either version 2.1 of the License, or
10# (at your option) any later version.
11#
12# systemd is distributed in the hope that it will be useful, but
13# WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15# General Public License for more details.
16#
17# You should have received a copy of the GNU Lesser General Public License
18# along with systemd; If not, see <https://www.gnu.org/licenses/>.
19
20__contains_word() {
21 local w word=$1; shift
22 for w in "$@"; do
23 [[ $w = "$word" ]] && return
24 done
25}
26
27_systemd_dissect() {
28 local comps
29 local cur=${COMP_WORDS[COMP_CWORD]} prev_1=${COMP_WORDS[COMP_CWORD-1]} prev_2=${COMP_WORDS[COMP_CWORD-2]} words cword
30 local -A OPTS=(
31 [STANDALONE]='-h --help --version
acb7d23d 32 --discover
808ec9df
AAF
33 --no-pager
34 --no-legend
35 -r --read-only
36 --mkdir
acb7d23d
AAF
37 --rmdir
38 --in-memory'
808ec9df
AAF
39 [ARG]='-m --mount -M
40 -u --umount -U
43aaa1b3
AAF
41 --attach
42 --detach
0cf16924 43 -l --list
acb7d23d
AAF
44 --mtree
45 --with
808ec9df
AAF
46 -x --copy-from
47 -a --copy-to
acb7d23d 48 --validate
808ec9df
AAF
49 --fsck
50 --growfs
51 --discard
52 --root-hash
53 --root-hash-sig
54 --verity-data
acb7d23d
AAF
55 --image-policy
56 --json
57 --loop-ref
58 --mtree-hash'
808ec9df
AAF
59 )
60
61 _init_completion || return
62
acb7d23d
AAF
63 if __contains_word "$prev_1" ${OPTS[STANDALONE]}; then
64 case $prev_1 in
65 -h|--help|--version|--discover)
66 return 0
67 ;;
68 esac
69 fi
70
71 if [[ "$cur" = -* ]]; then
72 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
73 return 0
74 fi
75
808ec9df
AAF
76 if __contains_word "$prev_1" ${OPTS[ARG]}; then
77 case $prev_1 in
43aaa1b3 78 -l|--list|--mtree|-m|--mount|-M|--attach|--detach|-x|--copy-from|-a|--copy-to|--verity-data|--validate|--with)
808ec9df
AAF
79 comps=$(compgen -A file -- "$cur")
80 compopt -o filenames
81 ;;
82 -u|--umount|-U)
acb7d23d 83 comps=$(compgen -A directory -- "$cur")
808ec9df
AAF
84 compopt -o dirnames
85 ;;
acb7d23d 86 --fsck|--growfs|--mtree-hash)
808ec9df
AAF
87 comps='yes no'
88 ;;
89 --discard)
90 comps='disabled loop all crypto'
91 ;;
92 --root-hash-sig)
93 comps="base64: $(compgen -A file -- "$cur")"
94 compopt -o filenames
95 ;;
96 --json)
97 comps='pretty short off'
98 ;;
99 esac
100 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
101 return 0
102 fi
103
104 if __contains_word "$prev_2" ${OPTS[ARG]}; then
105 case $prev_2 in
106 -m|--mount|-M)
acb7d23d 107 comps=$(compgen -A directory -- "$cur")
808ec9df
AAF
108 compopt -o dirnames
109 ;;
acb7d23d
AAF
110 --with)
111 comps=$(compgen -A command -- "$cur")
112 compopt -o filenames
113 ;;
808ec9df 114 *)
acb7d23d 115 comps=$(compgen -A file -- "$cur")
808ec9df
AAF
116 compopt -o filenames
117 ;;
118 esac
119 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
120 return 0
121 fi
122
808ec9df
AAF
123 COMPREPLY=( $(compgen -A file -- "$cur") )
124 compopt -o filenames
125 return 0
126}
127
128complete -F _systemd_dissect systemd-dissect