File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11function completion() {
2- commands=(" ${funcs[@]// _/ -} " )
3- if [ $# -eq 1 ]; then
4- shell=" $1 "
5- case " $shell " in
6- bash)
7- echo complete -W \" ${commands[*]} \" uceap
8- ;;
9- zsh)
10- echo " _uceap() { _arguments \" 1: :(${commands[*]} )\" }"
11- echo " compdef _uceap uceap"
12- ;;
13- * )
14- echo " [error] Unsupported shell: $shell "
15- return 1
16- ;;
17- esac
18- else
19- echo " [error] Invalid number of arguments"
20- return 1
21- fi
2+ commands=(" ${funcs[@]// _/ -} " )
3+ if [ $# -eq 1 ]; then
4+ shell=" $1 "
5+ case " $shell " in
6+ bash)
7+ cat << EOF
8+ _uceap_completions() {
9+ local cur prev opts
10+ COMPREPLY=()
11+ cur="\$ {COMP_WORDS[COMP_CWORD]}"
12+ prev="\$ {COMP_WORDS[COMP_CWORD-1]}"
13+ opts="${commands[*]} "
14+
15+ if [[ \$ COMP_CWORD -eq 1 ]]; then
16+ COMPREPLY=( \$ (compgen -W "\$ opts help" -- "\$ cur") )
17+ elif [[ \$ COMP_CWORD -eq 2 && "\$ prev" == "help" ]]; then
18+ COMPREPLY=( \$ (compgen -W "\$ opts" -- "\$ cur") )
19+ fi
20+ }
21+ complete -F _uceap_completions uceap
22+ EOF
23+ ;;
24+ zsh)
25+ echo ' _uceap() {
26+ local -a commands
27+ commands=(' " ${commands[*]} " ' )
28+ if (( CURRENT == 2 )); then
29+ _arguments "1: :((help ${commands[*]}))"
30+ elif (( CURRENT == 3 )) && [[ $words[2] == help ]]; then
31+ _arguments "2: :(${commands[*]})"
32+ fi
33+ }
34+ compdef _uceap uceap'
35+ ;;
36+ * )
37+ echo " [error] Unsupported shell: $shell "
38+ return 1
39+ ;;
40+ esac
41+ else
42+ echo " [error] Invalid number of arguments"
43+ return 1
44+ fi
2245}
2346
2447_completion_desc=" generate shell completion scripts"
You can’t perform that action at this time.
0 commit comments