forked from cleverwise/cya
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcya_completion
55 lines (44 loc) · 1.96 KB
/
cya_completion
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
# Version 1.2 - 13 February 2018
_cya()
{
local cur prev opts
cur=${COMP_WORDS[COMP_CWORD]}
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ -z ${CYA_COMMAND_MODE+x} ]; then
CYA_COMMAND_MODE=""
fi
if test "${prev}" == "cya" ; then
CYA_COMMAND_MODE=""
fi
# -----------------------------------------------------------------------------------------
if test "${CYA_COMMAND_MODE}" == "" ; then
case "${prev}" in
@(help|save|keep|restore|archive|configfile|directories|list|remove|script|updates|uses|version|software|credits|mydata))
CYA_COMMAND_MODE="${prev}" ;;
*)
CYA_COMMAND_MODE="" ;;
esac
fi
# -----------------------------------------------------------------------------------------
# =========================================================================================
# Start Testing Cases
# =========================================================================================
# -----------------------------------------------------------------------------------------
if test "${CYA_COMMAND_MODE}" == "keep" ; then
if test "$COMP_CWORD" == "2" ; then
COMPREPLY=( $(compgen -W "name" -- ${cur}) )
return 0
fi
if test "$COMP_CWORD" == "4" ; then
COMPREPLY=( $(compgen -W "overwrite archive" -- ${cur}) )
return 0
fi
fi
# -----------------------------------------------------------------------------------------
# -----------------------------------------------------------------------------------------
if test "${CYA_COMMAND_MODE}" == "" ; then
COMPREPLY=( $(compgen -W "help save keep restore archive configfile directories list remove script updates uses version software credits mydata" -- $cur) )
fi
# -----------------------------------------------------------------------------------------
}
complete -F _cya cya