File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #
2+ # Bash completion file for CakePHP console.
3+ # Copy this file to a file named `cake` under `/etc/bash_completion.d/`.
4+ # For more info check https://book.cakephp.org/4/en/console-commands/completion.html#how-to-enable-bash-autocompletion-for-the-cakephp-console
5+ #
6+
7+ _cake ()
8+ {
9+ local cur prev opts cake
10+ COMPREPLY=()
11+ cake=" ${COMP_WORDS[0]} "
12+ cur=" ${COMP_WORDS[COMP_CWORD]} "
13+ prev=" ${COMP_WORDS[COMP_CWORD-1]} "
14+
15+ if [[ " $cur " == -* ]] ; then
16+ if [[ ${COMP_CWORD} = 1 ]] ; then
17+ opts=$( ${cake} completion options)
18+ elif [[ ${COMP_CWORD} = 2 ]] ; then
19+ opts=$( ${cake} completion options " ${COMP_WORDS[1]} " )
20+ else
21+ opts=$( ${cake} completion options " ${COMP_WORDS[1]} " " ${COMP_WORDS[2]} " )
22+ fi
23+
24+ COMPREPLY=( $( compgen -W " ${opts} " -- ${cur} ) )
25+ return 0
26+ fi
27+
28+ if [[ ${COMP_CWORD} = 1 ]] ; then
29+ opts=$( ${cake} completion commands)
30+ COMPREPLY=( $( compgen -W " ${opts} " -- ${cur} ) )
31+ return 0
32+ fi
33+
34+ if [[ ${COMP_CWORD} = 2 ]] ; then
35+ opts=$( ${cake} completion subcommands $prev )
36+ COMPREPLY=( $( compgen -W " ${opts} " -- ${cur} ) )
37+ if [[ $COMPREPLY = " " ]] ; then
38+ _filedir
39+ return 0
40+ fi
41+ return 0
42+ fi
43+
44+ return 0
45+ }
46+
47+ complete -F _cake cake bin/cake
You can’t perform that action at this time.
0 commit comments