diff --git a/debian/install b/debian/install index ca9a131..8a6f7ad 100644 --- a/debian/install +++ b/debian/install @@ -1,3 +1,4 @@ *.php usr/share/php/domframework examples usr/share/doc/domframework docs/* usr/share/doc/domframework +docs/cli-completion usr/share/bash-completion/completions diff --git a/docs/cli-completion b/docs/cli-completion new file mode 100644 index 0000000..ad99712 --- /dev/null +++ b/docs/cli-completion @@ -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