Class: TomatoHarvest::CLI
- Inherits:
-
Thor
- Object
- Thor
- TomatoHarvest::CLI
- Defined in:
- lib/tomatoharvest/cli.rb
Constant Summary collapse
- DEFAULT_MINUTES =
25
Instance Method Summary collapse
- #add(name) ⇒ Object
- #list ⇒ Object
- #remove(id) ⇒ Object
- #start(id, minutes = DEFAULT_MINUTES) ⇒ Object
- #stop ⇒ Object
Instance Method Details
#add(name) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/tomatoharvest/cli.rb', line 8 def add(name) list = ListLoader.from_file task = Task.new(name) list.add(task) list.save! say "#{task.name} added with id #{task.id}" end |
#list ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/tomatoharvest/cli.rb', line 17 def list list = ListLoader.from_file table = list.map do |task| [task.id, task.name] end table.unshift(['id', 'name']) shell = Thor::Base.shell.new shell.print_table(table) end |
#remove(id) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/tomatoharvest/cli.rb', line 49 def remove(id) list = ListLoader.from_file task = list.remove(id) list.save! say "#{id} removed" end |
#start(id, minutes = DEFAULT_MINUTES) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/tomatoharvest/cli.rb', line 29 def start(id, minutes = DEFAULT_MINUTES) list = ListLoader.from_file task = list.find(id) config = Config.load.merge("name" => task.name) entry = TimeEntry.build_and_test(config) say "Timer started for #{task.name}" Timer.start(list, task.id, minutes: minutes, time_entry: entry) end |