systemd-analyze revision bb150966c0687d2fa94da0a36dabba90c1a84b8b
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer# systemd-analyze(1) completion -*- shell-script -*-
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer# This file is part of systemd.
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer# Copyright 2010 Ran Benita
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer# Copyright 2013 Harald Hoyer
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer# systemd is free software; you can redistribute it and/or modify it
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer# under the terms of the GNU Lesser General Public License as published by
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer# the Free Software Foundation; either version 2.1 of the License, or
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer# (at your option) any later version.
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer# systemd is distributed in the hope that it will be useful, but
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer# WITHOUT ANY WARRANTY; without even the implied warranty of
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer# General Public License for more details.
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer# You should have received a copy of the GNU Lesser General Public License
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer# along with systemd; If not, see <http://www.gnu.org/licenses/>.
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer__contains_word () {
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer local word=$1; shift
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer for w in $*; do [[ $w = $word ]] && return 0; done
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer_systemd_analyze() {
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer local i verb comps
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer local OPTS='--help --version --system --user --from-pattern --to-pattern --order --require'
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer local -A VERBS=(
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer [NO_OPTION]='time blame plot'
bb150966c0687d2fa94da0a36dabba90c1a84b8bHarald Hoyer [CRITICAL_CHAIN]='critical-chain'
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer _init_completion || return
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer for ((i=0; $i <= $COMP_CWORD; i++)); do
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} &&
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer verb=${COMP_WORDS[i]}
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer if [[ -z $verb && $cur = -* ]]; then
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer if [[ -z $verb ]]; then
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer comps=${VERBS[*]}
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer elif __contains_word "$verb" ${VERBS[NO_OPTION]}; then
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer if [[ $cur = -* ]]; then
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer comps='--help --version --system --user'
bb150966c0687d2fa94da0a36dabba90c1a84b8bHarald Hoyer elif __contains_word "$verb" ${VERBS[CRITICAL_CHAIN]}; then
bb150966c0687d2fa94da0a36dabba90c1a84b8bHarald Hoyer if [[ $cur = -* ]]; then
bb150966c0687d2fa94da0a36dabba90c1a84b8bHarald Hoyer comps='--help --version --system --user --fuzz'
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer elif __contains_word "$verb" ${VERBS[DOT]}; then
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer if [[ $cur = -* ]]; then
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer comps='--help --version --system --user --from-pattern --to-pattern --order --require'
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyer COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
83cb95b530ca5ae17bd9249774940840a4bbb667Harald Hoyercomplete -F _systemd_analyze systemd-analyze