Class: TheFox::Timr::Command::ContinueCommand

Inherits:
BasicCommand
  • Object
show all
Includes:
Error, Helper
Defined in:
lib/timr/command/continue_command.rb

Overview

Continue the previous paused [Track](TheFox::Timr::Model::Track).

Man page: [timr-continue(1)](../../../../man/timr-continue.1.html)

Constant Summary collapse

MAN_PATH =

Path to man page.

'man/timr-continue.1'

Instance Attribute Summary

Attributes inherited from BasicCommand

#cwd

Instance Method Summary collapse

Methods inherited from BasicCommand

create_command_from_argv, get_command_class_by_name, #shutdown

Constructor Details

#initialize(argv = Array.new) ⇒ ContinueCommand

Returns a new instance of ContinueCommand.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/timr/command/continue_command.rb', line 17

def initialize(argv = Array.new)
  super()
  
  @help_opt = false
  
  @date_opt = nil
  @time_opt = nil
  
  loop_c = 0 # Limit the loop.
  while loop_c < 1024 && argv.length > 0
    loop_c += 1
    arg = argv.shift
    
    case arg
    when '-h', '--help'
      @help_opt = true
    when '-d', '--date'
      @date_opt = argv.shift
    when '-t', '--time'
      @time_opt = argv.shift
    else
      raise ContinueCommandError, "Unknown argument '#{arg}'. See 'timr continue --help'."
    end
  end
end

Instance Method Details

#runObject

See BasicCommand#run.



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/timr/command/continue_command.rb', line 44

def run
  if @help_opt
    help
    return
  end
  
  @timr = Timr.new(@cwd)
  
  options = {
    :date => @date_opt,
    :time => @time_opt,
  }
  
  track = @timr.continue(options)
  unless track
    puts 'No running Track to continue.'
    return
  end
  
  puts '--- CONTINUED ---'
  puts track.to_compact_str
  puts @timr.stack
end