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
7 # Copyright 2013 Harald Hoyer
9 # systemd is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU Lesser General Public License as published by
11 # the Free Software Foundation; either version 2.1 of the License, or
12 # (at your option) any later version.
14 # systemd is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # General Public License for more details.
19 # You should have received a copy of the GNU Lesser General Public License
20 # along with systemd; If not, see <http://www.gnu.org/licenses/>.
23 local w word=$1; shift
25 [[ $w = "$word" ]] && return
31 machinectl list --no-legend --no-pager | { while read a b; do echo " $a"; done; };
36 local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
39 [STANDALONE]='-h --help --version --system --user --global --order --require --no-pager
40 --man=no --generators=yes'
41 [ARG]='-H --host -M --machine --fuzz --from-pattern --to-pattern'
45 [STANDALONE]='time blame plot dump unit-paths calendar'
46 [CRITICAL_CHAIN]='critical-chain'
48 [LOG_LEVEL]='log-level'
49 [LOG_TARGET]='log-target'
51 [SECCOMP_FILTER]='syscall-filter'
52 [SERVICE_WATCHDOGS]='service-watchdogs'
55 _init_completion || return
57 for ((i=0; i < COMP_CWORD; i++)); do
58 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} &&
59 ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
65 if __contains_word "$prev" ${OPTS[ARG]}; then
68 comps=$(compgen -A hostname)
71 comps=$( __get_machines )
74 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
78 if [[ -z $verb && $cur = -* ]]; then
79 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
83 if [[ -z $verb ]]; then
86 elif __contains_word "$verb" ${VERBS[STANDALONE]}; then
87 if [[ $cur = -* ]]; then
88 comps='--help --version --system --user --global'
91 elif __contains_word "$verb" ${VERBS[CRITICAL_CHAIN]}; then
92 if [[ $cur = -* ]]; then
93 comps='--help --version --system --user --fuzz'
96 elif __contains_word "$verb" ${VERBS[DOT]}; then
97 if [[ $cur = -* ]]; then
98 comps='--help --version --system --user --global --from-pattern --to-pattern --order --require'
101 elif __contains_word "$verb" ${VERBS[LOG_LEVEL]}; then
102 if [[ $cur = -* ]]; then
103 comps='--help --version --system --user'
105 comps='debug info notice warning err crit alert emerg'
108 elif __contains_word "$verb" ${VERBS[LOG_TARGET]}; then
109 if [[ $cur = -* ]]; then
110 comps='--help --version --system --user'
112 comps='console journal kmsg journal-or-kmsg null'
115 elif __contains_word "$verb" ${VERBS[SECCOMP_FILTER]}; then
116 if [[ $cur = -* ]]; then
117 comps='--help --version'
120 elif __contains_word "$verb" ${VERBS[VERIFY]}; then
121 if [[ $cur = -* ]]; then
122 comps='--help --version --system --user --global --man=no --generators=yes'
124 comps=$( compgen -A file -- "$cur" )
128 elif __contains_word "$verb" ${VERBS[SERVICE_WATCHDOGS]}; then
129 if [[ $cur = -* ]]; then
130 comps='--help --version --system --user'
137 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
141 complete -F _systemd_analyze systemd-analyze