1 # systemd-analyze(1) completion -*- shell-script -*-
2 # SPDX-License-Identifier: LGPL-2.1+
4 # This file is part of systemd.
6 # Copyright © 2010 Ran Benita
8 # systemd is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU Lesser General Public License as published by
10 # the Free Software Foundation; either version 2.1 of the License, or
11 # (at your option) any later version.
13 # systemd is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # General Public License for more details.
18 # You should have received a copy of the GNU Lesser General Public License
19 # along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 local w word=$1; shift
24 [[ $w = "$word" ]] && return
30 machinectl list --no-legend --no-pager | { while read a b; do echo " $a"; done; };
35 local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
38 [STANDALONE]='-h --help --version --system --user --global --order --require --no-pager
39 --man=no --generators=yes'
40 [ARG]='-H --host -M --machine --fuzz --from-pattern --to-pattern --root'
44 [STANDALONE]='time blame plot dump unit-paths calendar'
45 [CRITICAL_CHAIN]='critical-chain'
47 [LOG_LEVEL]='log-level'
48 [LOG_TARGET]='log-target'
50 [SECCOMP_FILTER]='syscall-filter'
51 [SERVICE_WATCHDOGS]='service-watchdogs'
52 [CAT_CONFIG]='cat-config'
55 local CONFIGS='systemd/bootchart.conf systemd/coredump.conf systemd/journald.conf
56 systemd/journal-remote.conf systemd/journal-upload.conf systemd/logind.conf
57 systemd/resolved.conf systemd/networkd.conf systemd/resolved.conf
58 systemd/sleep.conf systemd/system.conf systemd/timedated.conf
59 systemd/timesyncd.conf systemd/user.conf udev/udev.conf'
61 _init_completion || return
63 for ((i=0; i < COMP_CWORD; i++)); do
64 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} &&
65 ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
71 if __contains_word "$prev" ${OPTS[ARG]}; then
74 comps=$(compgen -A hostname)
77 comps=$( __get_machines )
80 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
84 if [[ -z $verb && $cur = -* ]]; then
85 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
89 if [[ -z $verb ]]; then
92 elif __contains_word "$verb" ${VERBS[STANDALONE]}; then
93 if [[ $cur = -* ]]; then
94 comps='--help --version --system --user --global --no-pager'
97 elif __contains_word "$verb" ${VERBS[CRITICAL_CHAIN]}; then
98 if [[ $cur = -* ]]; then
99 comps='--help --version --system --user --fuzz --no-pager'
102 elif __contains_word "$verb" ${VERBS[DOT]}; then
103 if [[ $cur = -* ]]; then
104 comps='--help --version --system --user --global --from-pattern --to-pattern --order --require'
107 elif __contains_word "$verb" ${VERBS[LOG_LEVEL]}; then
108 if [[ $cur = -* ]]; then
109 comps='--help --version --system --user'
111 comps='debug info notice warning err crit alert emerg'
114 elif __contains_word "$verb" ${VERBS[LOG_TARGET]}; then
115 if [[ $cur = -* ]]; then
116 comps='--help --version --system --user'
118 comps='console journal kmsg journal-or-kmsg null'
121 elif __contains_word "$verb" ${VERBS[SECCOMP_FILTER]}; then
122 if [[ $cur = -* ]]; then
123 comps='--help --version --no-pager'
126 elif __contains_word "$verb" ${VERBS[VERIFY]}; then
127 if [[ $cur = -* ]]; then
128 comps='--help --version --system --user --global --man=no --generators=yes'
130 comps=$( compgen -A file -- "$cur" )
134 elif __contains_word "$verb" ${VERBS[SERVICE_WATCHDOGS]}; then
135 if [[ $cur = -* ]]; then
136 comps='--help --version --system --user'
141 elif __contains_word "$verb" ${VERBS[CAT_CONFIG]}; then
142 if [[ $cur = -* ]]; then
143 comps='--help --version --root --no-pager'
144 elif [[ -z $cur ]]; then
148 comps="$CONFIGS $( compgen -A file -- "$cur" )"
153 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
157 complete -F _systemd_analyze systemd-analyze