-
Notifications
You must be signed in to change notification settings - Fork 3
/
lj.zsh-completion
60 lines (53 loc) · 1.07 KB
/
lj.zsh-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
56
57
58
59
60
#compdef lj
###
# List of log levels
###
_levels=(
'emergency'
'alert'
'critical'
'error'
'warning'
'notice'
'info'
'debug'
)
###
# Describe log levels
###
function _lumberjack_log_levels() {
_describe -t levels 'levels' _levels "$@"
}
###
# Lumberjack completion
###
function _lumberjack() {
typeset -A opt_args
local context state line curcontext="$curcontext"
# Set option arguments
_arguments -A \
'(-h --help)'{-h,--help}'[show help text and exit]' \
'(-v --version)'{-v,--version}'[show version information and exit]' \
'(-f --file)'{-f,--file}'[set log file and exit]' \
'(-l --level)'{-l,--level}'[set log level and exit]' \
# Set log level arguments
_arguments \
'1: :_lumberjack_log_levels' \
'*::arg:->args'
# Complete option arguments
case "$state" in
args )
case "$words[1]" in
--file|-f )
_arguments \
'1:file:_files'
;;
--level|-l )
_arguments \
'1:level:_lumberjack_log_levels'
;;
esac
;;
esac
}
_lumberjack "$@"