Merge pull request #29308 from aafeijoo-suse/dissect-fix

dissect: fix man and bash-completion
This commit is contained in:
Luca Boccassi
2023-09-25 19:16:08 +01:00
committed by GitHub
2 changed files with 38 additions and 13 deletions

View File

@@ -53,6 +53,12 @@
<cmdsynopsis>
<command>systemd-dissect <arg choice="opt" rep="repeat">OPTIONS</arg> <option>--copy-to</option> <arg choice="plain"><replaceable>IMAGE</replaceable></arg> <arg choice="opt"><replaceable>SOURCE</replaceable></arg> <arg choice="plain"><replaceable>PATH</replaceable></arg></command>
</cmdsynopsis>
<cmdsynopsis>
<command>systemd-dissect <arg choice="opt" rep="repeat">OPTIONS</arg> <option>--discover</option></command>
</cmdsynopsis>
<cmdsynopsis>
<command>systemd-dissect <arg choice="opt" rep="repeat">OPTIONS</arg> <option>--validate</option> <arg choice="plain"><replaceable>IMAGE</replaceable></arg></command>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
@@ -222,7 +228,6 @@
<varlistentry>
<term><option>--mtree</option></term>
<term><option>-l</option></term>
<listitem><para>Generates a BSD
<citerefentry project='die-net'><refentrytitle>mtree</refentrytitle><manvolnum>8</manvolnum></citerefentry>

View File

@@ -28,38 +28,59 @@ _systemd_dissect() {
local cur=${COMP_WORDS[COMP_CWORD]} prev_1=${COMP_WORDS[COMP_CWORD-1]} prev_2=${COMP_WORDS[COMP_CWORD-2]} words cword
local -A OPTS=(
[STANDALONE]='-h --help --version
--discover
--no-pager
--no-legend
-r --read-only
--mkdir
--rmdir'
--rmdir
--in-memory'
[ARG]='-m --mount -M
-u --umount -U
-l --list
--mtree
--with
-x --copy-from
-a --copy-to
--validate
--fsck
--growfs
--discard
--root-hash
--root-hash-sig
--verity-data
--json'
--image-policy
--json
--loop-ref
--mtree-hash'
)
_init_completion || return
if __contains_word "$prev_1" ${OPTS[STANDALONE]}; then
case $prev_1 in
-h|--help|--version|--discover)
return 0
;;
esac
fi
if [[ "$cur" = -* ]]; then
COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
return 0
fi
if __contains_word "$prev_1" ${OPTS[ARG]}; then
case $prev_1 in
-l|--list|-m|--mount|-M|-x|--copy-from|-a|--copy-to|--verity-data)
-l|--list|--mtree|-m|--mount|-M|-x|--copy-from|-a|--copy-to|--verity-data|--validate|--with)
comps=$(compgen -A file -- "$cur")
compopt -o filenames
;;
-u|--umount|-U)
comps=$(compgen -A directory -- "$cur" )
comps=$(compgen -A directory -- "$cur")
compopt -o dirnames
;;
--fsck|--growfs)
--fsck|--growfs|--mtree-hash)
comps='yes no'
;;
--discard)
@@ -80,11 +101,15 @@ _systemd_dissect() {
if __contains_word "$prev_2" ${OPTS[ARG]}; then
case $prev_2 in
-m|--mount|-M)
comps=$(compgen -A directory -- "$cur" )
comps=$(compgen -A directory -- "$cur")
compopt -o dirnames
;;
--with)
comps=$(compgen -A command -- "$cur")
compopt -o filenames
;;
*)
comps=$(compgen -A file -- "$cur" )
comps=$(compgen -A file -- "$cur")
compopt -o filenames
;;
esac
@@ -92,11 +117,6 @@ _systemd_dissect() {
return 0
fi
if [[ "$cur" = -* ]]; then
COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
return 0
fi
COMPREPLY=( $(compgen -A file -- "$cur") )
compopt -o filenames
return 0