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