]> kaliko git repositories - mpd-sima.git/blob - data/bash/completion.sh
Update bash completion (closes #44)
[mpd-sima.git] / data / bash / completion.sh
1 # Copyright (c) 2010, 2011, 2013, 2014, 2015, 2021 kaliko <kaliko@azylum.org>
2 #
3 #  This file is part of MPD_sima
4 #
5 #  MPD_sima is free software: you can redistribute it and/or modify
6 #  it under the terms of the GNU General Public License as published by
7 #  the Free Software Foundation, either version 3 of the License, or
8 #  (at your option) any later version.
9 #
10 #  MPD_sima is distributed in the hope that it will be useful,
11 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 #  GNU General Public License for more details.
14 #
15 #  You should have received a copy of the GNU General Public License
16 #  along with MPD_sima.  If not, see <http://www.gnu.org/licenses/>.
17 #
18 #
19
20 # Bash completion file
21 #
22 # On debian system either place this file in etc/bash_completion.d/ or source it
23 # in your barshrc.
24
25 _sima() {
26     local cur prev opts
27     COMPREPLY=()
28     _get_comp_words_by_ref cur prev
29     opts="-c --config \
30           -p --pid \
31           -l --log \
32           -v --log-level \
33           -S --host \
34           -P --port \
35           -h --help --version \
36           --var-dir \
37           -d --daemon \
38           config-test \
39           generate-config"
40
41     if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
42         COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
43         return 0
44     fi
45
46     case "${prev}" in
47         --var-dir)
48             _filedir -d
49             ;;
50         -v|--log-level)
51             COMPREPLY=( $(compgen -W "debug info warning error" -- ${cur} ))
52             ;;
53         -p|--pid|-l|--log)
54             _filedir
55             ;;
56         -c|--config)
57             _filedir
58             ;;
59         --host|-S)
60             COMPREPLY=( $(compgen -A hostname ${cur}) )
61             ;;
62         *)
63             ;;
64     esac
65 }
66 complete -F _sima mpd_sima
67 complete -F _sima mpd-sima
68
69 _simadb_cli() {
70     local cur prev opts
71     local IFS=$'\n'
72     COMPREPLY=()
73     _get_comp_words_by_ref cur prev
74     opts="--bl_curr_trk --bl_curr_art --bl_curr_al \
75       --bl_art --remove_bl --view_bl --purge_hist \
76         --dbfile -d \
77         --host -S --port -P \
78         --check_names -c \
79         --version -h --help"
80     opts=$(echo $opts | sed 's/ /\n/g')
81
82     if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
83         COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
84         return 0
85     fi
86
87     case "${prev}" in
88         --bl_curr*|--view_bl|--view_all|--purge_hist|--version|--help|-h)
89             return 0
90             ;;
91         -d|--dbfile)
92             _filedir
93             ;;
94         --host|-S)
95             COMPREPLY=( $(compgen -A hostname ${cur}) )
96             ;;
97         *)
98             ;;
99     esac
100 }
101 complete -F _simadb_cli simadb_cli