-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlysithea.completion.bash
80 lines (70 loc) · 1.46 KB
/
lysithea.completion.bash
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
# lysithea completion
# https://github.com/smallkirby/lysithea
_lysithea()
{
local cur prev words cword
_init_completion || return
local COMMANDS=(
"local"
"remote"
"help"
"version"
"init"
"extract"
"build"
"compress"
"error"
"exploit"
"logs"
"log"
"fetch"
"drothea"
"config"
"memo"
"clean"
)
local GENERIC_OPTIONS='
-h --help help
-v --verbose
-f --force
--nolog
--plain
'
# check if command is already specified
local command i
for (( i=0; i< ${#words[@]}-1; i++ )); do
if [[ ${COMMANDS[@]} =~ ${words[i]} ]]; then
command=${words[i]}
break
fi
done
# show command-specific option
if [[ "$cur" == -* ]]; then
case $command in
log)
COMPREPLY=( $( compgen -W '--all --no-pager'"$GENERIC_OPTIONS" -- "$cur" ) )
return 0;
;;
remote)
COMPREPLY=( $( compgen -W '-p --port -H --host --nobuild'"$GENERIC_OPTIONS" -- "$cur" ) )
return 0;
;;
clean)
COMPREPLY=( $( compgen -W '-a --all'"$GENERIC_OPTIONS" -- "$cur" ) )
return 0;
;;
*)
if [ -n "$command" ]; then
COMPREPLY=( $( compgen -W "$GENERIC_OPTIONS" -- "$cur" ) )
return 0
fi
;;
esac
fi
# show commands available if command is not set
if [ "$command" = "" ]; then
COMPREPLY=( $( compgen -W '${COMMANDS[@]}' -- "$cur" ) )
fi
return 0
} &&
complete -F _lysithea -o bashdefault -o default lysithea