207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen# systemd-cat(1) completion -*- shell-script -*-
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen#
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen# This file is part of systemd.
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen#
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen# Copyright 2014 Thomas H.P. Andersen
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen#
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen# systemd is free software; you can redistribute it and/or modify it
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen# under the terms of the GNU Lesser General Public License as published by
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen# the Free Software Foundation; either version 2.1 of the License, or
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen# (at your option) any later version.
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen#
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen# systemd is distributed in the hope that it will be useful, but
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen# WITHOUT ANY WARRANTY; without even the implied warranty of
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen# General Public License for more details.
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen#
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen# You should have received a copy of the GNU Lesser General Public License
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen# along with systemd; If not, see <http://www.gnu.org/licenses/>.
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen__contains_word() {
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen local w word=$1; shift
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen for w in "$@"; do
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen [[ $w = "$word" ]] && return
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen done
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen}
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen_systemd_cat() {
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen local i verb comps
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen local -A OPTS=(
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen [STANDALONE]='-h --help --version'
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen [ARG]='-t --identifier -p --priority --level-prefix'
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen )
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen _init_completion || return
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen if __contains_word "$prev" ${OPTS[ARG]}; then
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen case $prev in
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen --identifier|-t)
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen comps=''
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen ;;
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen --priority|-p)
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen comps='emerg alert crit err warning notice info debug'
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen ;;
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen --level-prefix)
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen comps='yes no'
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen ;;
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen esac
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen return 0
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen fi
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen}
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersen
207017017db91232189226bfcf29e61926310a9bThomas Hindoe Paaboel Andersencomplete -F _systemd_cat systemd-cat