1
0
mirror of https://github.com/systemd/systemd.git synced 2025-10-29 16:24:51 +03:00

networkctl: introduce --json option for "status" and "list" commands

When `--json` option is specified, "status" and "list" commands gives
the same information, as originally "list" just gives partial
information of "status" in different format.
This commit is contained in:
Yu Watanabe
2021-05-13 00:22:14 +09:00
parent fec7a9e0ac
commit bfc2b05e59
4 changed files with 153 additions and 2 deletions

View File

@@ -33,7 +33,7 @@ _networkctl() {
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} words cword
local -A OPTS=(
[STANDALONE]='-a --all -h --help --version --no-pager --no-legend -s --stats -l --full'
[ARG]='-n --lines'
[ARG]='-n --lines --json'
)
local -A VERBS=(
@@ -51,6 +51,19 @@ _networkctl() {
fi
done
if __contains_word "$prev" ${OPTS[ARG]}; then
case $prev in
--json)
comps=$(networkctl --json=help | sort 2>/dev/null)
;;
*)
return 0
;;
esac
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
return 0
fi
if [[ "$cur" = -* ]]; then
COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
return 0