Module: Hue::CLI
- Defined in:
- lib/hue/cli.rb,
lib/hue/cli/command.rb,
lib/hue/cli/commands/light.rb,
lib/hue/cli/commands/delete.rb,
lib/hue/cli/commands/lights.rb,
lib/hue/cli/commands/register.rb,
lib/hue/cli/processors/light_state_alias.rb
Defined Under Namespace
Modules: Commands, Processors
Classes: Command, Error
Constant Summary
collapse
- LOCATION =
File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
- ERROR_BRIDGE_CONNECTION_PROBLEM =
/execution expired|No route to host/
- @@retry_count =
0
Class Method Summary
collapse
Class Method Details
.bridge ⇒ Object
20
21
22
|
# File 'lib/hue/cli.rb', line 20
def self.bridge
Hue.application
end
|
.run(args = []) ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/hue/cli.rb', line 24
def self.run(args = [])
commands = commands_in_object_space
if args.size > 0
first_arg = args.shift
if command = commands[first_arg.to_sym]
command.new.execute(*args)
elsif first_arg.to_i > 0
Commands::Light.new.execute(first_arg, *args)
else
raise Error.new("Unknown command: #{first_arg}")
end
else
print_default
end
rescue Hue::Error => err
if ERROR_BRIDGE_CONNECTION_PROBLEM.match(err.message)
@@retry_count += 1
Hue.logger.warn("Error contacting bridge, verifying IP and trying again.")
Hue.register_bridges
if @@retry_count > 2
puts "Giving up contacting bridge after #{@@retry_count} retries."
bridge.print_config
else
retry
end
else
puts err.message
end
rescue Hue::CLI::Error => err
puts err.message
end
|