Module: Browserctl::Commands::Data
- Extended by:
- CliOutput
- Defined in:
- lib/browserctl/commands/data.rb
Overview
‘browserctl data <op> –scope <scope>` — unified verb for browser-side persistent data. Introduced in v0.15 (ADR-0021) as the replacement for the duplicated `cookie *` and `storage *` families.
Constant Summary
collapse
- USAGE =
"Usage: browserctl data <get|set|delete|list> --scope " \
"{cookies|localStorage|sessionStorage} [args]"
- SET_USAGE =
"usage: browserctl data set <page> <key> <value> --scope SCOPE [--domain D] [--path /]"
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
64
65
66
67
68
69
70
|
# File 'lib/browserctl/commands/data.rb', line 64
def self.(args, flag)
idx = args.index(flag)
return nil unless idx
args.delete_at(idx)
args.delete_at(idx)
end
|
58
59
60
61
62
|
# File 'lib/browserctl/commands/data.rb', line 58
def self.(args)
scope = (args, "--scope")
abort "missing required flag: --scope {cookies|localStorage|sessionStorage}" unless scope
scope
end
|
.run(client, args) ⇒ Object
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/browserctl/commands/data.rb', line 16
def self.run(client, args)
sub = args.shift or abort USAGE
case sub
when "get" then run_get(client, args)
when "set" then run_set(client, args)
when "delete" then run_delete(client, args)
when "list" then run_list(client, args)
else abort "unknown data subcommand '#{sub}'\n#{USAGE}"
end
end
|
.run_delete(client, args) ⇒ Object
46
47
48
49
50
|
# File 'lib/browserctl/commands/data.rb', line 46
def self.run_delete(client, args)
page = args.shift or abort "usage: browserctl data delete <page> --scope SCOPE"
scope = (args)
print_result(client.data_delete(page, scope: scope))
end
|
.run_get(client, args) ⇒ Object
27
28
29
30
31
32
|
# File 'lib/browserctl/commands/data.rb', line 27
def self.run_get(client, args)
page = args.shift or abort "usage: browserctl data get <page> <key> --scope SCOPE"
key = args.shift or abort "usage: browserctl data get <page> <key> --scope SCOPE"
scope = (args)
print_result(client.data_get(page, key, scope: scope))
end
|
.run_list(client, args) ⇒ Object
52
53
54
55
56
|
# File 'lib/browserctl/commands/data.rb', line 52
def self.run_list(client, args)
page = args.shift or abort "usage: browserctl data list <page> --scope SCOPE"
scope = (args)
print_result(client.data_list(page, scope: scope))
end
|
.run_set(client, args) ⇒ Object
36
37
38
39
40
41
42
43
44
|
# File 'lib/browserctl/commands/data.rb', line 36
def self.run_set(client, args)
page = args.shift or abort SET_USAGE
key = args.shift or abort SET_USAGE
value = args.shift or abort SET_USAGE
scope = (args)
domain = (args, "--domain")
path = (args, "--path") || "/"
print_result(client.data_set(page, key, value, scope: scope, domain: domain, path: path))
end
|