Module: Browserctl::Commands::Page
- Extended by:
- CliOutput
- Defined in:
- lib/browserctl/commands/page.rb
Constant Summary
collapse
- USAGE =
"Usage: browserctl page <open|close|list|focus> [args]"
Constants included
from CliOutput
CliOutput::AUTH_REQUIRED_EXIT_CODE
Class Method Summary
collapse
Methods included from CliOutput
exit_code_for, print_result, structured_error_line
Class Method Details
.run(client, args) ⇒ Object
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/browserctl/commands/page.rb', line 13
def self.run(client, args)
sub = args.shift or abort USAGE
case sub
when "open" then run_open(client, args)
when "close" then run_close(client, args)
when "list" then run_list(client)
when "focus" then run_focus(client, args)
else abort "unknown page subcommand '#{sub}'\n#{USAGE}"
end
end
|
.run_close(client, args) ⇒ Object
32
33
34
35
|
# File 'lib/browserctl/commands/page.rb', line 32
def self.run_close(client, args)
name = args.shift or abort "usage: browserctl page close <name>"
print_result(client.page_close(name))
end
|
.run_focus(client, args) ⇒ Object
41
42
43
44
|
# File 'lib/browserctl/commands/page.rb', line 41
def self.run_focus(client, args)
name = args.shift or abort "usage: browserctl page focus <name>"
print_result(client.page_focus(name))
end
|
.run_list(client) ⇒ Object
37
38
39
|
# File 'lib/browserctl/commands/page.rb', line 37
def self.run_list(client)
print_result(client.page_list)
end
|
.run_open(client, args) ⇒ Object
24
25
26
27
28
29
30
|
# File 'lib/browserctl/commands/page.rb', line 24
def self.run_open(client, args)
opts = Optimist.options(args) do
opt :url, "URL to navigate to", type: :string, short: "-u"
end
name = args.shift or abort "usage: browserctl page open <name> [--url URL]"
print_result(client.page_open(name, url: opts[:url]))
end
|