class Tlog::Command::Delete

Public Instance Methods

description() click to toggle source
# File lib/tlog/command/delete.rb, line 7
def description
  "deletes a time log"
end
execute(input, output) click to toggle source
# File lib/tlog/command/delete.rb, line 11
def execute(input, output)
  raise Tlog::Error::CommandInvalid, "Task does not exist" unless delete(input.args[0])
  output.line("Deleted log '#{input.args[0]}'")
end
name() click to toggle source
# File lib/tlog/command/delete.rb, line 3
def name
  "delete"
end
options(parser, options) click to toggle source
# File lib/tlog/command/delete.rb, line 16
def options(parser, options)
  parser.banner = "usage: tlog delete <tlog_name>"
end

Private Instance Methods

delete(log_name) click to toggle source
# File lib/tlog/command/delete.rb, line 22
def delete(log_name)
  storage.in_branch do |wd|
    log = storage.require_log(log_name)
    raise Tlog::Error::TimeLogNotFound, "Time log '#{log_name}' does not exist" unless log
    storage.delete_log(log) 
  end
end