Add bash-completion support to CLI
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1723 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
1
debian/install
vendored
1
debian/install
vendored
@@ -1,3 +1,4 @@
|
|||||||
*.php usr/share/php/domframework
|
*.php usr/share/php/domframework
|
||||||
examples usr/share/doc/domframework
|
examples usr/share/doc/domframework
|
||||||
docs/* usr/share/doc/domframework
|
docs/* usr/share/doc/domframework
|
||||||
|
docs/cli-completion usr/share/bash-completion/completions
|
||||||
|
|||||||
42
docs/cli-completion
Normal file
42
docs/cli-completion
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
_cli.php()
|
||||||
|
{
|
||||||
|
local cur prev opts base
|
||||||
|
COMPREPLY=()
|
||||||
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||||
|
|
||||||
|
if [ ! -x "$1" ]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# List of options (operations) available
|
||||||
|
opts="-h -expert -list -listmethods -listmethodsdetails"
|
||||||
|
controllers=$($1 -listonly)
|
||||||
|
opts="$opts $controllers"
|
||||||
|
|
||||||
|
if [ "${prev}" == "-list" ]; then
|
||||||
|
return 0
|
||||||
|
elif [ "${prev}" == "-listmethods" ] ||
|
||||||
|
[ "${prev}" == "-listmethodsdetails" ]; then
|
||||||
|
# Display the available class available
|
||||||
|
local control=$($1 -listonly)
|
||||||
|
COMPREPLY=( $(compgen -W "${control}" -- ${cur}) )
|
||||||
|
return 0
|
||||||
|
elif [ `$1 -listonly | grep -qx "${prev}" ; echo $?` == 0 ]; then
|
||||||
|
# Previous was a class : display the methods available
|
||||||
|
local methods=$($1 -listmethodsonly ${prev})
|
||||||
|
COMPREPLY=( $(compgen -W "${methods}" -- ${cur}) )
|
||||||
|
return 0
|
||||||
|
elif [ `$1 -listonly | grep -qx "${COMP_WORDS[COMP_CWORD-2]}" ; echo $?` == 0 ] &&
|
||||||
|
[ `$1 -listonly | grep -qx ${prev}" ; echo $?` == 0 ]; then
|
||||||
|
# A Class and a method available : propose the datas
|
||||||
|
# XXX : To be done
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
complete -F _cli.php cli.php
|
||||||
|
complete -F _cli.php ./cli/cli.php
|
||||||
Reference in New Issue
Block a user