require 'rake'
require_relative 'log_work'
require_relative 'jira'

namespace :log do
  desc 'Add worklog to JIRA'
  task :work, [:task_key, :time_spent, :comment, :go_back_in_days] do |t, args|
    args.with_defaults(:go_back_in_days => 0) 
    task_key = args[:task_key]
    task_key = task_key.to_i if task_key =~ /^[0-9]+$/
    LogWork.add_work(task_key, args[:time_spent], args[:comment], args[:go_back_in_days].to_i)
  end

  desc 'Send all worklogs to JIRA'
  task :send do
    LogWork.send_all(Jira)
  end
end
