forked from Codeception/Codeception
-
Notifications
You must be signed in to change notification settings - Fork 0
/
codecept_complete.sh
executable file
·92 lines (79 loc) · 2.76 KB
/
codecept_complete.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# Bash autocompletion for Codeception.
# Copy/symlink this script to /etc/bash_completion.d/codecept and restart your bash
_codecept()
{
local cur prev commands opts prefix base_opts base_cmds generate_cmds refactor_cmds
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
base_opts="--help --quiet --verbose --version --ansi --no-ansi --no-interaction"
base_cmds="analyze bootstrap build clean console help list run"
generate_cmds="generate:cept generate:cest generate:group\
generate:pageobject generate:scenarios\
generate:stepobject generate:suite\
generate:test generate:phpunit"
refactor_cmds="refactor:add-namespace"
case "$prev" in
codecept)
commands="${base_cmds} ${generate_cmds} ${refactor_cmds}"
;;
bootstrap)
opts="-ns --namespace ${base_opts}"
;;
help)
opts="--xml --format --raw ${base_opts}"
commands="${base_cmds} ${generate_cmds} ${refactor_cmds}"
;;
list)
opts="--xml --raw --format"
;;
run)
opts="--config --report --html --xml --tap --json --colors\
--no-colors --silent --steps --debug --coverage --no-exit\
--defer-flush --group --skip --skip-group --env ${base_opts}"
;;
add-namespace)
opts="--force -c --config ${base_opts}"
commands="${opts}"
;;
-c|--config)
_filedir '@(yml)'
return 0
;;
*)
opts="-c --config ${base_opts}"
commands="${opts}"
;;
esac
# ":" is treated as separate option so we need this workaround
# to get generate:* and refactor:* actions properly completed
if [[ "$prev" == ":" || "$cur" == ":" ]]; then
if [[ "$cur" == ":" ]]; then
prefix="$prev"
else
prefix="${COMP_WORDS[COMP_CWORD-2]}"
fi
case "$prefix" in
generate)
commands=$(echo "${generate_cmds}" | sed 's/generate://g')
;;
refactor)
commands=$(echo "${refactor_cmds}" | sed 's/refactor://g')
;;
esac
if [[ "$cur" == ":" ]]; then
COMPREPLY=( $( compgen -W "${commands}" ) )
return 0
fi
fi
if [[ ${cur} == -* ]]; then
COMPREPLY=($( compgen -W "${opts}" -- "${cur}" ))
else
COMPREPLY=($( compgen -W "${commands}" -- "${cur}" ))
fi
if [[ -z $COMPREPLY ]]; then
_filedir
fi
return 0;
}
complete -F _codecept $filenames codecept