2 # Ceph - scalable distributed file system
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
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]}
18 if [[ " -c --conf -i --in-file -o --out-file " =~ " ${prev} " ]]
20 #default autocomplete for options (file autocomplete)
25 if [[ "${cur:0:1}" == "-" ]] ;
27 COMPREPLY=( $(compgen -W "${options_noarg} ${options_arg}" -- $cur) )
31 for (( i=1 ; i<cnt ; i++ ))
33 #skip this word if it is option
34 if [[ " ${options_noarg} " =~ " ${COMP_WORDS[i]} " ]]
38 #skip this word and next if it is option with arg
39 if [[ " ${options_arg} " =~ " ${COMP_WORDS[i]} " ]]
44 hint_args[$((i-1))]="${COMP_WORDS[i]}"
48 COMPREPLY=( $(${COMP_WORDS[0]} --completion "${hint_args[@]}" 2>/dev/null) )
50 complete -F _ceph ceph