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]='--help --version --system --user --order --require --no-pager --man'
40 [ARG]='-H --host -M --machine --fuzz --from-pattern --to-pattern '
44 [STANDALONE]='time blame plot dump get-log-level get-log-target'
45 [CRITICAL_CHAIN]='critical-chain'
47 [LOG_LEVEL]='set-log-level'
48 [LOG_TARGET]='set-log-target'
50 [SECCOMP_FILTER]='syscall-filter'
53 _init_completion || return
55 for ((i=0; i < COMP_CWORD; i++)); do
56 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} &&
57 ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
63 if __contains_word "$prev" ${OPTS[ARG]}; then
66 comps=$(compgen -A hostname)
69 comps=$( __get_machines )
72 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
76 if [[ -z $verb && $cur = -* ]]; then
77 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
81 if [[ -z $verb ]]; then
84 elif __contains_word "$verb" ${VERBS[STANDALONE]}; then
85 if [[ $cur = -* ]]; then
86 comps='--help --version --system --user'
89 elif __contains_word "$verb" ${VERBS[CRITICAL_CHAIN]}; then
90 if [[ $cur = -* ]]; then
91 comps='--help --version --system --user --fuzz'
94 elif __contains_word "$verb" ${VERBS[DOT]}; then
95 if [[ $cur = -* ]]; then
96 comps='--help --version --system --user --from-pattern --to-pattern --order --require'
99 elif __contains_word "$verb" ${VERBS[LOG_LEVEL]}; then
100 if [[ $cur = -* ]]; then
101 comps='--help --version --system --user'
103 comps='debug info notice warning err crit alert emerg'
106 elif __contains_word "$verb" ${VERBS[LOG_TARGET]}; then
107 if [[ $cur = -* ]]; then
108 comps='--help --version --system --user'
110 comps='console journal kmsg journal-or-kmsg null'
113 elif __contains_word "$verb" ${VERBS[SECCOMP_FILTER]}; then
114 if [[ $cur = -* ]]; then
115 comps='--help --version'
118 elif __contains_word "$verb" ${VERBS[VERIFY]}; then
119 if [[ $cur = -* ]]; then
120 comps='--help --version --system --user --man'
122 comps=$( compgen -A file -- "$cur" )
128 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
132 complete -F _systemd_analyze systemd-analyze