-
Notifications
You must be signed in to change notification settings - Fork 56
/
nsscache.sh
111 lines (103 loc) · 3.33 KB
/
nsscache.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#/usr/bin/env bash
_nsscache ()
{
local cur prev options commands update_options other_options maps
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
options='-v --verbose -d --debug -c --config-file --version -h --help'
commands='update verify status repair help'
update_options='-f --full --force -m --map -h --help'
other_options='-m --map -h --help'
maps="passwd group shadow"
case "${COMP_CWORD}" in
1)
COMPREPLY=( $(compgen -W "${options} ${commands}" -- "${cur}" ))
;;
2)
case "${prev}" in
update)
COMPREPLY=( $( compgen -W "${update_options}" -- "${cur}" ))
return 0
;;
verify|status|repair)
COMPREPLY=( $( compgen -W "${other_options}" -- "${cur}" ))
return 0
;;
-c|--config-file)
COMPREPLY=( $( compgen -o plusdirs -f -- "${cur}" ))
return 0
;;
-h|--help|--version|help)
return 0
;;
-v|--verbose|-d|--debug )
COMPREPLY=( $( compgen -W "${commands}" -- "${cur}" ))
return 0
;;
esac
;;
3)
case "${prev}" in
update)
COMPREPLY=( $( compgen -W "${update_options}" -- "${cur}" ))
return 0
;;
verify|status|repair)
COMPREPLY=( $( compgen -W "${other_options}" -- "${cur}" ))
return 0
;;
-m|--map)
COMPREPLY=( $( compgen -W "${maps}" -- "${cur}" ))
return 0
;;
-f|--full|--force)
COMPREPLY=()
return 0
;;
*)
COMPREPLY=( $( compgen -W "${commands}" -- "${cur}" ))
return 0
;;
esac
;;
4)
case "${prev}" in
update)
COMPREPLY=( $( compgen -W "${update_options}" -- "${cur}" ))
return 0
;;
verify|status|repair)
COMPREPLY=( $( compgen -W "${other_options}" -- "${cur}" ))
return 0
;;
-m|--map)
COMPREPLY=( $( compgen -W "${maps}" -- "${cur}" ))
return 0
;;
-f|--full|--force)
COMPREPLY=()
return 0
;;
*)
COMPREPLY=( $( compgen -W "${commands}" -- "${cur}" ))
return 0
;;
esac
;;
5)
case "${prev}" in
-m|--map)
COMPREPLY=( $( compgen -W "${maps}" -- "${cur}" ))
return 0
;;
esac
;;
*)
COMPREPLY=()
return 0
;;
esac
}
complete -o filenames -F _nsscache nsscache
# ex: filetype=sh