1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

bash-completion: move shell-completion for log-level or friends to systemctl

This commit is contained in:
Yu Watanabe 2019-12-20 11:29:11 +09:00 committed by Zbigniew Jędrzejewski-Szmek
parent 1234d0f63e
commit 4171837be6
2 changed files with 9 additions and 24 deletions

View File

@ -211,6 +211,9 @@ _systemctl () {
[FILE]='link switch-root'
[TARGETS]='set-default'
[MACHINES]='list-machines'
[LOG_LEVEL]='log-level'
[LOG_TARGET]='log-target'
[SERVICE_WATCHDOGS]='service-watchdogs'
)
for ((i=0; i < COMP_CWORD; i++)); do
@ -326,6 +329,12 @@ _systemctl () {
elif __contains_word "$verb" ${VERBS[TARGETS]}; then
comps=$( __systemctl $mode list-unit-files --type target --full --all "$cur*" \
| { while read -r a b; do echo " $a"; done; } )
elif __contains_word "$verb" ${VERBS[LOG_LEVEL]}; then
comps='debug info notice warning err crit alert emerg'
elif __contains_word "$verb" ${VERBS[LOG_TARGET]}; then
comps='console journal kmsg journal-or-kmsg null'
elif __contains_word "$verb" ${VERBS[SERVICE_WATCHDOGS]}; then
comps='on off'
fi
COMPREPLY=( $(compgen -o filenames -W '$comps' -- "$cur_orig") )

View File

@ -58,11 +58,8 @@ _systemd_analyze() {
[STANDALONE]='time blame plot dump unit-paths exit-status condition calendar timestamp timespan'
[CRITICAL_CHAIN]='critical-chain'
[DOT]='dot'
[LOG_LEVEL]='log-level'
[LOG_TARGET]='log-target'
[VERIFY]='verify'
[SECCOMP_FILTER]='syscall-filter'
[SERVICE_WATCHDOGS]='service-watchdogs'
[CAT_CONFIG]='cat-config'
[SECURITY]='security'
)
@ -119,20 +116,6 @@ _systemd_analyze() {
comps='--help --version --system --user --global --from-pattern --to-pattern --order --require'
fi
elif __contains_word "$verb" ${VERBS[LOG_LEVEL]}; then
if [[ $cur = -* ]]; then
comps='--help --version --system --user'
else
comps='debug info notice warning err crit alert emerg'
fi
elif __contains_word "$verb" ${VERBS[LOG_TARGET]}; then
if [[ $cur = -* ]]; then
comps='--help --version --system --user'
else
comps='console journal kmsg journal-or-kmsg null'
fi
elif __contains_word "$verb" ${VERBS[SECCOMP_FILTER]}; then
if [[ $cur = -* ]]; then
comps='--help --version --no-pager'
@ -148,13 +131,6 @@ _systemd_analyze() {
compopt -o filenames
fi
elif __contains_word "$verb" ${VERBS[SERVICE_WATCHDOGS]}; then
if [[ $cur = -* ]]; then
comps='--help --version --system --user'
else
comps='on off'
fi
elif __contains_word "$verb" ${VERBS[CAT_CONFIG]}; then
if [[ $cur = -* ]]; then
comps='--help --version --root --no-pager'