Class: Timelog::Command::Start

Inherits:
Timelog::Command show all
Defined in:
lib/timelog/command/start.rb

Instance Attribute Summary

Attributes inherited from Timelog::Command

#arguments, #book, #session

Instance Method Summary collapse

Methods inherited from Timelog::Command

get, inherited, #initialize, known, register, #time_in_arguments

Constructor Details

This class inherits a constructor from Timelog::Command

Instance Method Details

#executeObject

Raises:

  • (InvalidArgumentError)


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/timelog/command/start.rb', line 4

def execute
  time = time_in_arguments
  raise InvalidArgumentError if arguments.size > 2

  client = arguments.shift
  project = arguments.shift

  client = book.clients.id(client) unless client.nil?
  project = book.projects.id(client, project) unless project.nil?

  entry = book.entries.active_or_new
  entry.client = client
  entry.project = project

  book.entries.start entry, at: time
  "entry started"
end

#helpObject



22
23
24
# File 'lib/timelog/command/start.rb', line 22

def help
  "usage: timelog start [<client>] [<project>] [<time>]"
end