61 lines
1.1 KiB
Text
61 lines
1.1 KiB
Text
#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 "$@"
|
|
|