-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path_crontroll
38 lines (35 loc) · 1.08 KB
/
_crontroll
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
#compdef crontroll
_crontroll_commands() {
local -a crontroll_ary
crontroll_ary=(
'status':'get status of cronjob'
'enable':'enable cronjob'
'disable':'disable cronjob'
'reload':'reload crontab from files in $CRONDIR'
'list':'list all cron jobs and if they are enabled or disabled in a pretty list'
'crontab':'list all configured cron jobs, in the format of a normal crontab'
'now':'run cronjob now'
'now_force':'run cronjob now, even if it is disabled'
'now_wait':'run cronjob now, even if it is disabled, and wait until it finishes'
)
_describe -t commands "crontroll commands" crontroll_ary -V crontroll_commands
}
local curcontext="$curcontext" state line
_arguments -C \
'1: :->command' \
'*:: :->options'
case $state in
(command)
_alternative \
_crontroll_commands \
;;
(options)
local -a crontroll_cronjobs
local crondir=${CRONDIR:-~/.cron}
crontroll_cronjobs=(
$crondir/*(N)
)
crontroll_cronjobs=( ${crontroll_cronjobs#$crondir/} )
_describe -t cronjobs "crontroll cronjobs" crontroll_cronjobs
;;
esac