exe/yee in xilight-0.1.7 vs exe/yee in xilight-0.1.8
- old
+ new
@@ -1,10 +1,10 @@
#!/usr/bin/env ruby
require "xilight"
require "dry/cli"
-
+require 'pry-byebug'
module Xilight
module CLI
def self.config_path
File.join(Dir.home, ".config", ".yeelights")
@@ -49,16 +49,25 @@
exit(1)
end
def self.discover
::Xilight::CLI.config = {
- 'yeelights' => ::Xilight::Yeelight.discover.each do |light|
+ 'yeelights' => ::Xilight::Yeelight.discover.map do |light|
light.instance_variables.map{|v| [v.to_s[1..-1], light.instance_variable_get(v)] }.to_h
end
}
+ self.list
end
+ def self.list
+ current_config = ::Xilight::CLI.config
+ current_lights = current_config.fetch('yeelights', [])
+ current_lights.each_with_index do |light, index|
+ puts "Light ##{index} => #{(light['name'] || light['id'])}@#{light['host']}"
+ end
+ end
+
module Commands
extend Dry::CLI::Registry
class Version < Dry::CLI::Command
desc "Print version"
@@ -90,14 +99,10 @@
example [
""
]
def call(**)
- current_config = ::Xilight::CLI.config
- current_lights = current_config.fetch('yeelights', [])
- current_lights.each_with_index do |light, index|
- puts "Light ##{index} => #{(light['name'] || light['id'])}@#{light['host']}"
- end
+ ::Xilight::CLI.list
end
end
class Rgb < Dry::CLI::Command
desc "Set RGB for Yeelight"
\ No newline at end of file