Class: Browserctl::Commands::Watch

Inherits:
Object
  • Object
show all
Extended by:
CliOutput
Defined in:
lib/browserctl/commands/watch.rb

Class Method Summary collapse

Methods included from CliOutput

print_result

Class Method Details

.run(client, args) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/browserctl/commands/watch.rb', line 11

def self.run(client, args)
  opts = Optimist.options(args) do
    banner "Usage: browserctl watch <page> <selector> [--timeout N]"
    opt :timeout, "Seconds to wait (default: 30)", default: 30.0, short: "-t"
  end
  name     = args.shift
  selector = args.shift
  abort "usage: browserctl watch <page> <selector> [--timeout N]" unless name && selector
  unless opts[:timeout].positive?
    warn "Error: --timeout must be a positive number"
    exit 1
  end
  print_result(client.watch(name, selector, timeout: opts[:timeout]))
end