Class: Browserctl::Commands::Inspect

Inherits:
Object
  • Object
show all
Defined in:
lib/browserctl/commands/inspect.rb

Class Method Summary collapse

Class Method Details

.run(client, args) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/browserctl/commands/inspect.rb', line 6

def self.run(client, args)
  name = args.shift or abort "usage: browserctl inspect <page>"
  res = client.inspect_page(name)
  if res[:error]
    warn "Error: #{res[:error]}"
    exit 1
  end
  url = res[:devtools_url]
  puts "Opening DevTools for '#{name}':"
  puts "  #{url}"
  opener = RUBY_PLATFORM =~ /darwin/ ? "open" : "xdg-open"
  system(opener, url)
end