Class: Muxoro::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/muxoro/cli.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#help_askedObject (readonly)

Returns the value of attribute help_asked.



7
8
9
# File 'lib/muxoro/cli.rb', line 7

def help_asked
  @help_asked
end

#orange_bgObject (readonly)

Returns the value of attribute orange_bg.



7
8
9
# File 'lib/muxoro/cli.rb', line 7

def orange_bg
  @orange_bg
end

#orange_fgObject (readonly)

Returns the value of attribute orange_fg.



7
8
9
# File 'lib/muxoro/cli.rb', line 7

def orange_fg
  @orange_fg
end

#orange_zoneObject (readonly)

Returns the value of attribute orange_zone.



7
8
9
# File 'lib/muxoro/cli.rb', line 7

def orange_zone
  @orange_zone
end

#red_bgObject (readonly)

Returns the value of attribute red_bg.



7
8
9
# File 'lib/muxoro/cli.rb', line 7

def red_bg
  @red_bg
end

#red_fgObject (readonly)

Returns the value of attribute red_fg.



7
8
9
# File 'lib/muxoro/cli.rb', line 7

def red_fg
  @red_fg
end

#red_zoneObject (readonly)

Returns the value of attribute red_zone.



7
8
9
# File 'lib/muxoro/cli.rb', line 7

def red_zone
  @red_zone
end

#short_sleep_intervalObject (readonly)

Returns the value of attribute short_sleep_interval.



7
8
9
# File 'lib/muxoro/cli.rb', line 7

def short_sleep_interval
  @short_sleep_interval
end

#sleep_intervalObject (readonly)

Returns the value of attribute sleep_interval.



7
8
9
# File 'lib/muxoro/cli.rb', line 7

def sleep_interval
  @sleep_interval
end

#timeObject (readonly)

Returns the value of attribute time.



7
8
9
# File 'lib/muxoro/cli.rb', line 7

def time
  @time
end

#tmuxObject (readonly)

Returns the value of attribute tmux.



9
10
11
# File 'lib/muxoro/cli.rb', line 9

def tmux
  @tmux
end

Instance Method Details

#helpObject



11
12
13
14
15
# File 'lib/muxoro/cli.rb', line 11

def help
  return nil unless help_asked
  $stderr.puts help_text
  true
end

#init(args) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/muxoro/cli.rb', line 17

def init args
  @help_asked           = args.include? ":help"
  @time                 = get_int_from( args, 'time:', 25 ) * 60
  @sleep_interval       = get_int_from args, 'sleep_interval:', 60
  @short_sleep_interval = get_int_from args, 'short_sleep_interval:', 10
  @orange_zone          = get_int_from args, 'orange_zone:', 300
  @red_zone             = get_int_from args, 'red_zone:',60
  @red_bg               = get_str_from args, 'red_bg:', 'red'
  @orange_bg            = get_str_from args, 'orange_bg:', '#882288'
  @red_fg               = get_str_from args, 'red_fg:', 'black'
  @orange_fg            = get_str_from args, 'orange_fg:', 'green'

  # @logger = Logger.new File.expand_local_path{ %W{ .. .. log #{self.class.name.split("::").last}.log} }
  # log "#{inspect} initialized"
  self
end

#resetObject



34
35
36
# File 'lib/muxoro/cli.rb', line 34

def reset
  tmux.set_left_status fg: 'cyan', time: '', bg: '#222222'
end

#run!(session_name) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/muxoro/cli.rb', line 38

def run! session_name
  # log ">>>run!"
  @tmux = Tmux.new session_name # , @logger
  # log  "tmux created"
  loop do
    set_current_status
    break if finished?
    wait_tick
  end
  reset
end