12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/esphome/cli/completion.rb', line 12
def run(prefix: ARGV[1].to_s,
comp_line: ENV["COMP_LINE"],
multi: false)
argv = Shellwords.split(comp_line || "")[1..]
dashboard_uri, argv = (argv)
return if argv.length > 1 && !multi
dashboard = ESPHome::Dashboard.new(dashboard_uri)
puts dashboard.devices
.filter_map { |device| device["name"] }
.select { |name| name.start_with?(prefix) }
.sort
rescue HTTPX::Error, IOError, SocketError, SystemCallError, Timeout::Error
nil
end
|