lib/td/command/sched.rb in td-0.11.2 vs lib/td/command/sched.rb in td-0.11.3

- old
+ new

@@ -134,20 +134,24 @@ end def sched_update(op) require 'td/command/job' # job_priority_id_of + newname = nil cron = nil sql = nil db_name = nil result = nil timezone = nil delay = nil priority = nil retry_limit = nil type = nil + op.on('-n', '--newname NAME', 'change the schedule\'s name') {|n| + newname = n + } op.on('-s', '--schedule CRON', 'change the schedule') {|s| cron = s } op.on('-q', '--query SQL', 'change the query') {|s| sql = s @@ -181,14 +185,14 @@ } op.on('-T', '--type TYPE', 'set query type (hive or pig)') {|s| type = s } + curname = op.cmd_parse - name = op.cmd_parse - params = {} + params['name'] = newname if newname params['cron'] = cron if cron params['query'] = sql if sql params['database'] = db_name if db_name params['result'] = result if result params['timezone'] = timezone if timezone @@ -203,18 +207,22 @@ end client = get_client begin - client.update_schedule(name, params) + client.update_schedule(curname, params) rescue NotFoundError cmd_debug_error $! - $stderr.puts "Schedule '#{name}' does not exist." + $stderr.puts "Schedule '#{curname}' does not exist." $stderr.puts "Use '#{$prog} " + Config.cl_options_string + "sched:list' to show list of the schedules." exit 1 end - $stderr.puts "Schedule '#{name}' is updated." + if newname && curname != newname + puts "Schedule '#{curname}' is updated and its name changed to '#{newname}'." + else + puts "Schedule '#{curname}' is updated." + end end def sched_history(op) require 'td/command/job' # job_priority_name_of