]> git.proxmox.com Git - ceph.git/blame - ceph/src/bash_completion/ceph
import 15.2.4
[ceph.git] / ceph / src / bash_completion / ceph
CommitLineData
7c673cae
FG
1#
2# Ceph - scalable distributed file system
3#
4# This is free software; you can redistribute it and/or
5# modify it under the terms of the GNU Lesser General Public
6# License version 2.1, as published by the Free Software
7# Foundation.
8#
9
10_ceph()
11{
12 local options_noarg="-h --help -s --status -w --watch --watch-debug --watch-info --watch-sec --watch-warn --watch-error --version -v --verbose --concise"
13 local options_arg="-c --conf -i --in-file -o --out-file --id --user -n --name --cluster --admin-daemon --admin-socket -f --format --connect-timeout"
14 local cnt=${#COMP_WORDS[@]}
15 local cur=${COMP_WORDS[COMP_CWORD]}
16 local prev=${COMP_WORDS[COMP_CWORD-1]}
17
18 if [[ " -c --conf -i --in-file -o --out-file " =~ " ${prev} " ]]
19 then
20 #default autocomplete for options (file autocomplete)
21 compopt -o default
22 COMPREPLY=()
23 return 0
24 fi
25 if [[ "${cur:0:1}" == "-" ]] ;
26 then
27 COMPREPLY=( $(compgen -W "${options_noarg} ${options_arg}" -- $cur) )
28 return 0
29 fi
e306af50 30 declare -a hint_args
7c673cae
FG
31 for (( i=1 ; i<cnt ; i++ ))
32 do
33 #skip this word if it is option
34 if [[ " ${options_noarg} " =~ " ${COMP_WORDS[i]} " ]]
35 then
36 continue
37 fi
38 #skip this word and next if it is option with arg
39 if [[ " ${options_arg} " =~ " ${COMP_WORDS[i]} " ]]
40 then
41 ((i++));
42 continue
43 fi
44 hint_args[$((i-1))]="${COMP_WORDS[i]}"
45 done
46
47 local IFS=$'\n'
48 COMPREPLY=( $(${COMP_WORDS[0]} --completion "${hint_args[@]}" 2>/dev/null) )
49}
50complete -F _ceph ceph