Module: Browserctl::Commands::Dialog

Extended by:
CliOutput
Defined in:
lib/browserctl/commands/dialog.rb

Constant Summary collapse

USAGE =
"Usage: browserctl dialog <accept|dismiss> <page> [text]"

Class Method Summary collapse

Methods included from CliOutput

print_result

Class Method Details

.run(client, args) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/browserctl/commands/dialog.rb', line 12

def self.run(client, args)
  sub = args.shift or abort USAGE
  case sub
  when "accept"  then run_accept(client, args)
  when "dismiss" then run_dismiss(client, args)
  else abort "unknown dialog subcommand '#{sub}'\n#{USAGE}"
  end
end

.run_accept(client, args) ⇒ Object



21
22
23
24
25
# File 'lib/browserctl/commands/dialog.rb', line 21

def self.run_accept(client, args)
  name = args.shift or abort "usage: browserctl dialog accept <page> [text]"
  text = args.shift
  print_result(client.dialog_accept(name, text: text))
end

.run_dismiss(client, args) ⇒ Object



27
28
29
30
# File 'lib/browserctl/commands/dialog.rb', line 27

def self.run_dismiss(client, args)
  name = args.shift or abort "usage: browserctl dialog dismiss <page>"
  print_result(client.dialog_dismiss(name))
end