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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user