Sha256: c134efcbc1c4e87c2df6ca9c5e9bde3d3cf01f2ae4141576553f33ffd1b98966

Contents?: true

Size: 972 Bytes

Versions: 1

Compression:

Stored size: 972 Bytes

Contents

require 'thor'

module TomatoHarvest
  class CLI < ::Thor
    DEFAULT_MINUTES = 25

    desc "add", "add a task"
    def add(name)
      task = Task.new(name)
      List.add(task)
      say "#{task.name} added with id #{task.id}"
    end

    desc "list", "list all tasks"
    def list
      list = List.all.map do |task|
        [task.id, task.name]
      end
      list.unshift(['id', 'name'])

      shell = Thor::Base.shell.new
      shell.print_table(list)
    end

    desc "start", "start a task"
    def start(id, minutes = DEFAULT_MINUTES)
      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(task.id, minutes: minutes, time_entry: entry)
    end

    desc "stop", "stop current timer"
    def stop
      if Timer.stop
        say "Timer stopped"
      else
        say "Timer not running"
      end
    end


  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tomatoharvest-0.0.1 lib/tomatoharvest/cli.rb