Class: Tlog::Command::Stop

Inherits:
Tlog::Command show all
Defined in:
lib/tlog/command/stop.rb

Instance Attribute Summary

Attributes inherited from Tlog::Command

#date_time_format, #seconds_format, #storage

Instance Method Summary collapse

Instance Method Details

#descriptionObject



8
9
10
# File 'lib/tlog/command/stop.rb', line 8

def description
  "ends a task for a time log"
end

#execute(input, output) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/tlog/command/stop.rb', line 12

def execute(input, output)
  updated_log = stop
  output.line("Stopped '#{updated_log.name}'")
  current_branch = storage.current_branch
  if input.options[:all]
    commit_output = commit_working_changes(input.options[:message])
    commit_message = input.options[:message]
    output.line("#{commit_output}")
  end
end

#nameObject



4
5
6
# File 'lib/tlog/command/stop.rb', line 4

def name 
  "stop"
end

#options(parser, options) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/tlog/command/stop.rb', line 23

def options(parser, options)
  parser.banner = "usage: tlo stop"

  parser.on("-a", "--all", "Stop current time log and commit tracked working changes") do |all|
    options[:all] = all
  end

  parser.on("-m", "--message <commit_message>", "The commit message you want to be associated with this commit") do |message|
    options[:message] = message
  end
end