d9256bac4da4241cb5d97960c899390839f2c6e5Thomas Hindoe Paaboel Andersen# systemd-cgtop(1) completion -*- shell-script -*-
d9256bac4da4241cb5d97960c899390839f2c6e5Thomas Hindoe Paaboel Andersen# This file is part of systemd.
d9256bac4da4241cb5d97960c899390839f2c6e5Thomas Hindoe Paaboel Andersen# Copyright 2014 Thomas H.P. Andersen
d9256bac4da4241cb5d97960c899390839f2c6e5Thomas Hindoe Paaboel Andersen# systemd is free software; you can redistribute it and/or modify it
d9256bac4da4241cb5d97960c899390839f2c6e5Thomas Hindoe Paaboel Andersen# under the terms of the GNU Lesser General Public License as published by
d9256bac4da4241cb5d97960c899390839f2c6e5Thomas Hindoe Paaboel Andersen# the Free Software Foundation; either version 2.1 of the License, or
d9256bac4da4241cb5d97960c899390839f2c6e5Thomas Hindoe Paaboel Andersen# (at your option) any later version.
d9256bac4da4241cb5d97960c899390839f2c6e5Thomas Hindoe Paaboel Andersen# systemd is distributed in the hope that it will be useful, but
d9256bac4da4241cb5d97960c899390839f2c6e5Thomas Hindoe Paaboel Andersen# WITHOUT ANY WARRANTY; without even the implied warranty of
d9256bac4da4241cb5d97960c899390839f2c6e5Thomas Hindoe Paaboel Andersen# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d9256bac4da4241cb5d97960c899390839f2c6e5Thomas Hindoe Paaboel Andersen# General Public License for more details.
d9256bac4da4241cb5d97960c899390839f2c6e5Thomas Hindoe Paaboel Andersen# You should have received a copy of the GNU Lesser General Public License
d9256bac4da4241cb5d97960c899390839f2c6e5Thomas Hindoe Paaboel Andersen# along with systemd; If not, see <http://www.gnu.org/licenses/>.
d9256bac4da4241cb5d97960c899390839f2c6e5Thomas Hindoe Paaboel Andersen__contains_word() {
d9256bac4da4241cb5d97960c899390839f2c6e5Thomas Hindoe Paaboel Andersen local w word=$1; shift
d9256bac4da4241cb5d97960c899390839f2c6e5Thomas Hindoe Paaboel Andersen for w in "$@"; do
d9256bac4da4241cb5d97960c899390839f2c6e5Thomas Hindoe Paaboel Andersen [[ $w = "$word" ]] && return
96a6426f30dc9bf3c4dd1f61548c334fa12034dfEvgeny Vereshchagin__get_machines() {
96a6426f30dc9bf3c4dd1f61548c334fa12034dfEvgeny Vereshchagin machinectl list --no-legend --no-pager | { while read a b; do echo " $a"; done; };
d9256bac4da4241cb5d97960c899390839f2c6e5Thomas Hindoe Paaboel Andersen_systemd_cgtop() {
d9256bac4da4241cb5d97960c899390839f2c6e5Thomas Hindoe Paaboel Andersen local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
a2accacb984b784c9a5215ece6c0bf42f096e229Evgeny Vereshchagin [STANDALONE]='-h --help --version -p -t -c -m -i -b --batch -r --raw -k -P'
a2accacb984b784c9a5215ece6c0bf42f096e229Evgeny Vereshchagin [ARG]='--cpu --depth -M --machine --recursive -n --iterations -d --delay --order'
d9256bac4da4241cb5d97960c899390839f2c6e5Thomas Hindoe Paaboel Andersen _init_completion || return
96a6426f30dc9bf3c4dd1f61548c334fa12034dfEvgeny Vereshchagin if __contains_word "$prev" ${OPTS[ARG]}; then
96a6426f30dc9bf3c4dd1f61548c334fa12034dfEvgeny Vereshchagin comps=$( __get_machines )
73b73b762c801f04e291c551dd6eb47e146dca88Evgeny Vereshchagin comps='yes no'
a2accacb984b784c9a5215ece6c0bf42f096e229Evgeny Vereshchagin comps='path tasks cpu memory io'
96a6426f30dc9bf3c4dd1f61548c334fa12034dfEvgeny Vereshchagin COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
d9256bac4da4241cb5d97960c899390839f2c6e5Thomas Hindoe Paaboel Andersen COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
d9256bac4da4241cb5d97960c899390839f2c6e5Thomas Hindoe Paaboel Andersencomplete -F _systemd_cgtop systemd-cgtop