forked from vieter-v/vieter
Compare commits
No commits in common. "768da5b7907e27282744aa25946325d7df2d79f8" and "c0b739035b58ca711d9da52a2ca8c09a8eeed8b8" have entirely different histories.
768da5b790
...
c0b739035b
|
|
@ -1,30 +0,0 @@
|
||||||
module schedule
|
|
||||||
|
|
||||||
import cli
|
|
||||||
import cron.expression { parse_expression }
|
|
||||||
import time
|
|
||||||
|
|
||||||
// cmd returns the cli submodule for previewing a cron schedule.
|
|
||||||
pub fn cmd() cli.Command {
|
|
||||||
return cli.Command{
|
|
||||||
name: 'schedule'
|
|
||||||
usage: 'schedule'
|
|
||||||
description: 'Preview the behavior of a cron schedule.'
|
|
||||||
flags: [
|
|
||||||
cli.Flag{
|
|
||||||
name: 'count'
|
|
||||||
description: 'How many scheduled times to show.'
|
|
||||||
flag: cli.FlagType.int
|
|
||||||
default_value: ['5']
|
|
||||||
},
|
|
||||||
]
|
|
||||||
execute: fn (cmd cli.Command) ? {
|
|
||||||
ce := parse_expression(cmd.args.join(' '))?
|
|
||||||
count := cmd.flags.get_int('count')?
|
|
||||||
|
|
||||||
for t in ce.next_n(time.now(), count)? {
|
|
||||||
println(t)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -121,20 +121,6 @@ pub fn (ce &CronExpression) next_from_now() ?time.Time {
|
||||||
return ce.next(time.now())
|
return ce.next(time.now())
|
||||||
}
|
}
|
||||||
|
|
||||||
// next_n returns the n next occurences of the expression, given a starting
|
|
||||||
// time.
|
|
||||||
pub fn (ce &CronExpression) next_n(ref time.Time, n int) ?[]time.Time {
|
|
||||||
mut times := []time.Time{cap: n}
|
|
||||||
|
|
||||||
times << ce.next(ref)?
|
|
||||||
|
|
||||||
for i in 1 .. n {
|
|
||||||
times << ce.next(times[i - 1])?
|
|
||||||
}
|
|
||||||
|
|
||||||
return times
|
|
||||||
}
|
|
||||||
|
|
||||||
// parse_range parses a given string into a range of sorted integers, if
|
// parse_range parses a given string into a range of sorted integers, if
|
||||||
// possible.
|
// possible.
|
||||||
fn parse_range(s string, min int, max int, mut bitv []bool) ? {
|
fn parse_range(s string, min int, max int, mut bitv []bool) ? {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import server
|
||||||
import cli
|
import cli
|
||||||
import console.git
|
import console.git
|
||||||
import console.logs
|
import console.logs
|
||||||
import console.schedule
|
|
||||||
import cron
|
import cron
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
@ -28,7 +27,6 @@ fn main() {
|
||||||
git.cmd(),
|
git.cmd(),
|
||||||
cron.cmd(),
|
cron.cmd(),
|
||||||
logs.cmd(),
|
logs.cmd(),
|
||||||
schedule.cmd(),
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
app.setup()
|
app.setup()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue