Class: TheFox::Timr::Command::StatusCommand

Inherits:
BasicCommand show all
Includes:
Error
Defined in:
lib/timr/command/status_command.rb

Overview

Print [Stack](TheFox::Timr::Model::Stack) Status.

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

Constant Summary collapse

MAN_PATH =

Path to man page.

'man/timr-status.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) ⇒ StatusCommand

Returns a new instance of StatusCommand.



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

def initialize(argv = Array.new)
  super()
  
  @help_opt = false
  
  @verbose_opt = false
  @full_opt = false
  @reverse_opt = false
  
  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 '-v', '--verbose'
      @verbose_opt = true
    when '-f', '--full'
      @full_opt = true
    when '-r', '--reverse'
      @reverse_opt = true
    else
      raise StatusCommandError, "Unknown argument '#{arg}'. See 'timr stop --help'."
    end
  end
end

Instance Method Details

#runObject

See BasicCommand#run.



48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/timr/command/status_command.rb', line 48

def run
  if @help_opt
    help
    return
  end
  
  @timr = Timr.new(@cwd)
  
  if @full_opt
    print_full_table
  else
    print_small_table
  end
end