class Tlog::Command::Start

Public Instance Methods

description() click to toggle source
# File lib/tlog/command/start.rb, line 8
def description
  "starts a new task for a time log"
end
execute(input, output) click to toggle source
# File lib/tlog/command/start.rb, line 12
def execute(input, output)
  updated_log = start(input.options[:description])
  output.line("Started '#{updated_log.name}'")
end
name() click to toggle source
# File lib/tlog/command/start.rb, line 4
def name 
  "start"
end
options(parser, options) click to toggle source
# File lib/tlog/command/start.rb, line 17
def options(parser, options)
  parser.banner = "usage: tlog start"

    parser.on("-d", "--description <description>") do |description|
      options[:description] = description
    end
end

Private Instance Methods

start(entry_description) click to toggle source
# File lib/tlog/command/start.rb, line 27
def start(entry_description)
  storage.in_branch do |wd|
    checked_out_log = storage.checkout_value
    raise Tlog::Error::CheckoutInvalid, "No time log is checked out" unless checked_out_log
    log = storage.require_log(checked_out_log)
    raise Tlog::Error::TimeLogNotFound, "Time log '#{checked_out_log}' does not exist" unless log
    unless storage.start_log(log, entry_description)
      raise Tlog::Error::CommandInvalid, "Time log '#{checked_out_log}' is already in progress"
    end
    log
  end
end