Class: Browserctl::Commands::Click

Inherits:
Object
  • Object
show all
Extended by:
CliOutput
Defined in:
lib/browserctl/commands/click.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
25
26
# File 'lib/browserctl/commands/click.rb', line 11

def self.run(client, args)
  opts = Optimist.options(args) do
    banner "Usage: browserctl click <page> <selector>\n       " \
           "browserctl click <page> --ref <ref>"
    opt :ref, "Snapshot ref to click", type: :string, short: "-r"
  end
  name = args.shift
  if opts[:ref]
    abort "usage: browserctl click <page> --ref <ref>" unless name
    print_result(client.click(name, ref: opts[:ref]))
  else
    selector = args.shift
    abort "usage: browserctl click <page> <selector>" unless name && selector
    print_result(client.click(name, selector))
  end
end