Refresh the promp status every 10 seconds (when showing a new prompt)
This commit is contained in:
parent
cb245ba880
commit
bc9fbf73a6
7
bin/huec
7
bin/huec
|
@ -47,13 +47,17 @@ def status_line(blb)
|
||||||
end
|
end
|
||||||
|
|
||||||
def prompt_status
|
def prompt_status
|
||||||
Huey::Bulb.all.map do |blb|
|
reload_needed = Time.now - @prompt_stamp > 10
|
||||||
|
prompt_str = Huey::Bulb.all.map do |blb|
|
||||||
|
blb.reload if reload_needed
|
||||||
if blb.reachable
|
if blb.reachable
|
||||||
blb.on ? Rainbow("o").bright.green : Rainbow("o").red
|
blb.on ? Rainbow("o").bright.green : Rainbow("o").red
|
||||||
else
|
else
|
||||||
Rainbow("x").bright.red
|
Rainbow("x").bright.red
|
||||||
end
|
end
|
||||||
end.join
|
end.join
|
||||||
|
@prompt_stamp = Time.now if reload_needed
|
||||||
|
prompt_str
|
||||||
end
|
end
|
||||||
|
|
||||||
def lights
|
def lights
|
||||||
|
@ -264,5 +268,6 @@ puts
|
||||||
puts "All done!"
|
puts "All done!"
|
||||||
puts "Use 'commands' to see a list of additional commands to pry's."
|
puts "Use 'commands' to see a list of additional commands to pry's."
|
||||||
puts
|
puts
|
||||||
|
@prompt_stamp = Time.now
|
||||||
Pry.config.prompt = proc { "#{prompt_status}> " }
|
Pry.config.prompt = proc { "#{prompt_status}> " }
|
||||||
binding.pry(quiet: true)
|
binding.pry(quiet: true)
|
||||||
|
|
Reference in New Issue