mount: convert to VERB_COMMAND and add --introspect-cli

The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added.

Options are now in two groups: "Common options" and Mount options". In
--help, for systemd-mount, both groups are shown. For systemd-umount, only
the first. This changes the behaviour a bit: previously, both groups were
shown together as one list. I think the new behaviour is actually a bit
better, because it makes it easier for the user to figure out that the
commands share common options and one of the commands has its private
second group. But if people think that the previous behaviour should
be restored, we could add a display options to squish the groups back
together.

--help now goes through the pager, like other commands with --no-pager.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-08-25 09:36:33 +02:00
parent 5f45122e75
commit f976133dbf
2 changed files with 56 additions and 45 deletions
@@ -80,6 +80,7 @@ INTROSPECTABLE=(
systemd-machine-id-setup
systemd-measure
systemd-modules-load
systemd-mount
systemd-mstack
systemd-mute-console
systemd-network-generator
@@ -119,6 +120,7 @@ INTROSPECTABLE=(
systemd-tpm2-clear
systemd-tpm2-setup
systemd-tty-ask-password-agent
systemd-umount
systemd-update-done
systemd-validatefs
systemd-veritysetup
@@ -181,6 +183,15 @@ systemd-dissect --introspect-cli | jq -e \
systemd-id128 --introspect-cli | jq -e \
'.commands[0].verbs | map(.names[0]) | contains(["new", "machine-id", "show", "help"])'
if command -v systemd-mount >/dev/null; then
systemd-mount --introspect-cli | jq -e \
'[.commands[].names[0]] | sort == ["systemd-mount", "systemd-umount"]'
# --tmpfs is only valid for systemd-mount
(! systemd-mount --tmpfs 2>&1) | grep "one argument required" >/dev/null
(! systemd-umount --tmpfs 2>&1) | grep "unrecognized option" >/dev/null
fi
systemd-mstack --introspect-cli | jq -e \
'[.commands[].names[0]] | sort == ["mount.mstack", "systemd-mstack"]'