Class: TogglCLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Shell
Defined in:
lib/toggl_cli.rb

Constant Summary collapse

FILTERS =
%w(no description user clear).freeze
SHOW_REPORTS_COLUMNS =
%w(description user duration).freeze

Instance Method Summary collapse

Instance Method Details

#batchObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/toggl_cli.rb', line 25

def batch
  # TEMP
  # source_project = select_project("Select the source project")
  # source_task = select_task("Select the source task", source_project["id"])
  source_project = { "name" => "technical (fake)", "id" => 9800254 }
  source_task = { "name" => "No task", "id" => nil }
  # END TEMP

  reports = find_reports(source_project["id"], source_task["id"])
  show_reports_info(reports)
  reports = filter_reports(reports)

  unless no?("Move these reports to a new project / task (enter 'n' or 'no' to cancel)")
    target_project = select_project("Select the target project")
    target_task = select_task("Select the target task", target_project["id"])

    say(
      "Will move #{reports.count} reports, " \
      "from #{source_project['name']} > #{source_task['name']} " \
      "to #{target_project['name']} > #{target_task['name']}"
    )
    if yes?("Are you sure? (enter 'y' or 'yes' to continue)")
      say("MOVING!!!")
    end
  end
  TogglCache::Data::ReportRepository.new.create_or_update(report)
end