lib/td/command/sched.rb in td-0.10.4 vs lib/td/command/sched.rb in td-0.10.5
- old
+ new
@@ -9,25 +9,29 @@
scheds = client.schedules
rows = []
scheds.each {|sched|
- rows << {:Name => sched.name, :Cron => sched.cron, :Query => sched.query}
+ rows << {:Name => sched.name, :Cron => sched.cron, :Result => sched.rset_name, :Query => sched.query}
}
rows = rows.sort_by {|map|
map[:Name]
}
- puts cmd_render_table(rows, :fields => [:Name, :Cron, :Query])
+ puts cmd_render_table(rows, :fields => [:Name, :Cron, :Result, :Query])
end
def sched_create(op)
db_name = nil
+ result = nil
op.on('-d', '--database DB_NAME', 'use the database (required)') {|s|
db_name = s
}
+ op.on('-r', '--result RESULT_TABLE', 'write result to the result table (use result:create command)') {|s|
+ result = s
+ }
name, cron, sql = op.cmd_parse
unless db_name
$stderr.puts "-d, --database DB_NAME option is required."
@@ -38,11 +42,11 @@
# local existance check
get_database(client, db_name)
begin
- first_time = client.create_schedule(name, :cron=>cron, :query=>sql, :database=>db_name)
+ first_time = client.create_schedule(name, :cron=>cron, :query=>sql, :database=>db_name, :result=>result)
rescue AlreadyExistsError
cmd_debug_error $!
$stderr.puts "Schedule '#{name}' already exists."
exit 1
end
@@ -97,13 +101,13 @@
exit 1
end
rows = []
history.each {|j|
- rows << {:Time => j.scheduled_at.localtime, :JobID => j.job_id, :Status => j.status}
+ rows << {:Time => j.scheduled_at.localtime, :JobID => j.job_id, :Status => j.status, :Result=>j.rset_name}
}
- puts cmd_render_table(rows, :fields => [:JobID, :Time, :Status])
+ puts cmd_render_table(rows, :fields => [:JobID, :Time, :Status, :Result])
end
end
end