Debian Codegraph @

lib/launcher/flags/flags.go

raw
1 // Package flags ...
2 package flags
3
4 import "strings"
5
6 // Flag name of a command line argument of the browser, also known as command line flag or switch.
7 // List of available flags: https://peter.sh/experiments/chromium-command-line-switches
8 type Flag string
9
10 // TODO: we should automatically generate all the flags here.
11 const (
12 // UserDataDir https://chromium.googlesource.com/chromium/src/+/master/docs/user_data_dir.md
13 UserDataDir Flag = "user-data-dir"
14
15 // Headless mode. Whether to run browser in headless mode. A mode without visible UI.
16 Headless Flag = "headless"
17
18 // App flag.
19 App Flag = "app"
20
21 // RemoteDebuggingPort flag.
22 RemoteDebuggingPort Flag = "remote-debugging-port"
23
24 // NoSandbox flag.
25 NoSandbox Flag = "no-sandbox"
26
27 // ProxyServer flag.
28 ProxyServer Flag = "proxy-server"
29
30 // WorkingDir flag.
31 WorkingDir Flag = "rod-working-dir"
32
33 // Env flag.
34 Env Flag = "rod-env"
35
36 // XVFB flag.
37 XVFB Flag = "rod-xvfb"
38
39 // ProfileDir flag.
40 ProfileDir = "profile-directory"
41
42 // Preferences flag.
43 Preferences Flag = "rod-preferences"
44
45 // Leakless flag.
46 Leakless Flag = "rod-leakless"
47
48 // Bin is the browser executable file path. If it's empty, launcher will automatically search or download the bin.
49 Bin Flag = "rod-bin"
50
51 // KeepUserDataDir flag.
52 KeepUserDataDir Flag = "rod-keep-user-data-dir"
53
54 // Arguments for the command. Such as
55 // chrome-bin http://a.com http://b.com
56 // The "http://a.com" and "http://b.com" are the arguments.
57 Arguments Flag = ""
58 )
59
60 // Check if the flag name is valid.
61 func (f Flag) Check() {
62 if strings.Contains(string(f), "=") {
63 panic("flag name should not contain '='")
64 }
65 }
66
67 // NormalizeFlag normalize the flag name, remove the leading dash.
68 func (f Flag) NormalizeFlag() Flag {
69 return Flag(strings.TrimLeft(string(f), "-"))
70 }