From 81a55d3b3b16c05824102e2c197e05684b4b7c6b Mon Sep 17 00:00:00 2001 From: Adam Kupczyk Date: Thu, 31 Mar 2016 10:08:07 +0200 Subject: [PATCH] bash_completion: now bash completion uses improved "ceph --completion" Signed-off-by: Adam Kupczyk --- src/bash_completion/ceph | 95 +++++++++++++++------------------------- 1 file changed, 36 insertions(+), 59 deletions(-) diff --git a/src/bash_completion/ceph b/src/bash_completion/ceph index eef885d051f..beec700e854 100644 --- a/src/bash_completion/ceph +++ b/src/bash_completion/ceph @@ -1,73 +1,50 @@ # # Ceph - scalable distributed file system # -# Copyright (C) 2011 Wido den Hollander -# # This is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License version 2.1, as published by the Free Software -# Foundation. See file COPYING. +# Foundation. # _ceph() { - local cur prev - - COMPREPLY=() - cur="${COMP_WORDS[COMP_CWORD]}" - prev="${COMP_WORDS[COMP_CWORD-1]}" - prevprev="${COMP_WORDS[COMP_CWORD-2]}" + local options_noarg="-h --help -s --status -w --watch --watch-debug --watch-info --watch-sec --watch-warn --watch-error --version -v --verbose --concise" + local options_arg="-c --conf -i --in-file -o --out-file --id --user -n --name --cluster --admin-daemon --admin-socket -f --format --connect-timeout" + local cnt=${#COMP_WORDS[@]} + local cur=${COMP_WORDS[COMP_CWORD]} + local prev=${COMP_WORDS[COMP_CWORD-1]} - if [[ ${cur} == -* ]] ; then - COMPREPLY=( $(compgen -W "--conf -c --name --id -m --version -s --status -w --watch -o --out-file -i --in-file" -- ${cur}) ) - return 0 - fi + if [[ " -c --conf -i --in-file -o --out-file " =~ " ${prev} " ]] + then + #default autocomplete for options (file autocomplete) + compopt -o default + COMPREPLY=() + return 0 + fi + if [[ "${cur:0:1}" == "-" ]] ; + then + COMPREPLY=( $(compgen -W "${options_noarg} ${options_arg}" -- $cur) ) + return 0 + fi + declare -A hint_args + for (( i=1 ; i/dev/null) ) } complete -F _ceph ceph -- 2.39.5