Add option parsing to huec (similar to hued)

This commit is contained in:
Paul van Tilburg 2014-11-20 21:37:48 +01:00
parent 5820e87af6
commit 38cbd0b7d0
1 changed files with 27 additions and 0 deletions

View File

@ -9,8 +9,10 @@
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
require "hued/version"
require "huey"
require "logger"
require "optparse"
require "pp"
require "pry"
require "rainbow"
@ -156,5 +158,30 @@ Groups
EOT
end
# Option parsing
options = {:config_dir => "config"}
opt_parser = OptionParser.new do |opts|
opts.banner = "Usage: huec [options]"
opts.separator ""
opts.on("-c", "--config-dir [CONFDIR] ",
"set an alternative configuration directory") do |cd|
options[:config_dir] = cd
end
opts.on("--hue-debug", "log hue bridge communication output") do
options[:hue_debug] = true
end
opts.on_tail("-h", "--help", "show this help message") do
puts opts
exit
end
opts.on_tail("-v", "--version", "show version") do
puts "Hued version #{Hued::VERSION}"
exit
end
end
Pry.config.prompt = proc { "#{prompt_status}> " }
binding.pry(quiet: true)