]> kaliko git repositories - mpd-sima.git/blob - data/bash/completion.sh
0fc633f15d9477feaeabdd11cac4b3d8464436fd
[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           create-db \
40           generate-config \
41           purge-history"
42
43     if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
44         COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
45         return 0
46     fi
47
48     case "${prev}" in
49         --var-dir)
50             _filedir -d
51             ;;
52         -v|--log-level)
53             COMPREPLY=( $(compgen -W "debug info warning error" -- ${cur} ))
54             ;;
55         -p|--pid|-l|--log)
56             _filedir
57             ;;
58         -c|--config)
59             _filedir
60             ;;
61         --host|-S)
62             COMPREPLY=( $(compgen -A hostname ${cur}) )
63             ;;
64         *)
65             ;;
66     esac
67 }
68 complete -F _sima mpd_sima
69 complete -F _sima mpd-sima
70
71 _simadb_cli() {
72     local cur prev opts
73     local IFS=$'\n'
74     COMPREPLY=()
75     _get_comp_words_by_ref cur prev
76     opts="--bl_curr_trk --bl_curr_art --bl_curr_al \
77       --bl_art --remove_bl --view_bl --purge_hist \
78         --dbfile -d \
79         --host -S --port -P \
80         --check_names -c \
81         --version -h --help"
82     opts=$(echo $opts | sed 's/ /\n/g')
83
84     if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
85         COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
86         return 0
87     fi
88
89     case "${prev}" in
90         --bl_curr*|--view_bl|--view_all|--purge_hist|--version|--help|-h)
91             return 0
92             ;;
93         -d|--dbfile)
94             _filedir
95             ;;
96         --host|-S)
97             COMPREPLY=( $(compgen -A hostname ${cur}) )
98             ;;
99         *)
100             ;;
101     esac
102 }
103 complete -F _simadb_cli simadb_cli