1#![allow(missing_docs)]
8
9use clap::{ArgAction, Args, Parser, Subcommand, ValueEnum, ValueHint};
10
11#[derive(Debug, Parser)]
13#[command(
14 name = "browser-automation-cli",
15 version,
16 author,
17 about = "One-shot browser automation CLI (Chrome CDP). BORN, EXECUTE, FINALIZE, DIE.",
18 long_about = None,
19 propagate_version = true,
20 after_help = "Examples:\n \
21browser-automation-cli doctor --json\n \
22browser-automation-cli goto https://example.com --json\n \
23browser-automation-cli schema run\n \
24browser-automation-cli run --script steps.ndjson --json-steps\n \
25browser-automation-cli config path\n\n\
26Exit codes follow sysexits-style mapping (2 usage, 69 unavailable, 70 software, 124 timeout).\n\
27Config is XDG-only (config set); product settings do not read process environment variables."
28)]
29pub struct Cli {
30 #[command(flatten)]
32 pub globals: GlobalOpts,
33
34 #[command(subcommand)]
36 pub command: Commands,
37}
38
39#[derive(Debug, Clone, Args)]
43pub struct GlobalOpts {
44 #[arg(long, global = true, action = ArgAction::SetTrue, help_heading = "Output")]
46 pub json: bool,
47
48 #[arg(
50 long = "json-steps",
51 global = true,
52 action = ArgAction::SetTrue,
53 help_heading = "Output"
54 )]
55 pub json_steps: bool,
56
57 #[arg(
59 short = 'q',
60 long = "quiet",
61 global = true,
62 action = ArgAction::SetTrue,
63 conflicts_with_all = ["verbose", "debug"],
64 help_heading = "Output"
65 )]
66 pub quiet: bool,
67
68 #[arg(
70 short = 'v',
71 long = "verbose",
72 global = true,
73 action = ArgAction::SetTrue,
74 conflicts_with = "quiet",
75 help_heading = "Output"
76 )]
77 pub verbose: bool,
78
79 #[arg(
81 long = "debug",
82 global = true,
83 action = ArgAction::SetTrue,
84 conflicts_with = "quiet",
85 help_heading = "Output"
86 )]
87 pub debug: bool,
88
89 #[arg(
91 long = "plain",
92 global = true,
93 action = ArgAction::SetTrue,
94 help_heading = "Output"
95 )]
96 pub plain: bool,
97
98 #[arg(
100 long,
101 global = true,
102 default_value_t = 0,
103 value_name = "SECS",
104 help_heading = "Timeouts"
105 )]
106 pub timeout: u64,
107
108 #[arg(
113 long = "max-concurrency",
114 global = true,
115 default_value_t = 0,
116 value_name = "N",
117 help_heading = "Parallelism"
118 )]
119 pub max_concurrency: usize,
120
121 #[arg(
123 long,
124 global = true,
125 default_value_t = 0,
126 value_name = "SECS",
127 help_heading = "Timeouts"
128 )]
129 pub step_timeout: u64,
130
131 #[arg(
133 long,
134 global = true,
135 action = ArgAction::SetTrue,
136 help_heading = "Browser"
137 )]
138 pub headed: bool,
139
140 #[arg(
142 long,
143 global = true,
144 value_name = "DIR",
145 value_hint = ValueHint::DirPath,
146 help_heading = "Browser"
147 )]
148 pub artifacts_dir: Option<std::path::PathBuf>,
149
150 #[arg(long, global = true, value_name = "LANG", help_heading = "Output")]
155 pub lang: Option<String>,
156
157 #[arg(
159 long,
160 global = true,
161 action = ArgAction::SetTrue,
162 help_heading = "Browser"
163 )]
164 pub capture_console: bool,
165
166 #[arg(
168 long,
169 global = true,
170 action = ArgAction::SetTrue,
171 help_heading = "Browser"
172 )]
173 pub capture_network: bool,
174
175 #[arg(
177 long,
178 global = true,
179 action = ArgAction::SetTrue,
180 help_heading = "Robots"
181 )]
182 pub ignore_robots: bool,
183
184 #[arg(
186 long,
187 global = true,
188 action = ArgAction::SetTrue,
189 help_heading = "Robots"
190 )]
191 pub i_accept_robots_risk: bool,
192
193 #[arg(
195 long,
196 global = true,
197 action = ArgAction::SetTrue,
198 help_heading = "Categories"
199 )]
200 pub category_memory: bool,
201
202 #[arg(
204 long,
205 global = true,
206 action = ArgAction::SetTrue,
207 help_heading = "Categories"
208 )]
209 pub category_extensions: bool,
210
211 #[arg(
213 long,
214 global = true,
215 action = ArgAction::SetTrue,
216 help_heading = "Categories"
217 )]
218 pub category_third_party: bool,
219
220 #[arg(
222 long,
223 global = true,
224 action = ArgAction::SetTrue,
225 help_heading = "Categories"
226 )]
227 pub category_webmcp: bool,
228
229 #[arg(
231 long,
232 global = true,
233 action = ArgAction::SetTrue,
234 help_heading = "Categories"
235 )]
236 pub experimental_screencast: bool,
237
238 #[arg(
240 long,
241 global = true,
242 action = ArgAction::SetTrue,
243 help_heading = "Categories"
244 )]
245 pub experimental_vision: bool,
246
247 #[arg(
249 long,
250 global = true,
251 action = ArgAction::SetTrue,
252 help_heading = "MITM"
253 )]
254 pub mitm: bool,
255
256 #[arg(
258 long,
259 global = true,
260 value_name = "DIR",
261 value_hint = ValueHint::DirPath,
262 help_heading = "MITM"
263 )]
264 pub mitm_ca_dir: Option<std::path::PathBuf>,
265
266 #[arg(
268 long,
269 global = true,
270 value_name = "FILE",
271 value_hint = ValueHint::FilePath,
272 help_heading = "MITM"
273 )]
274 pub mitm_har: Option<std::path::PathBuf>,
275
276 #[arg(long, global = true, value_name = "HOSTS", help_heading = "MITM")]
278 pub mitm_hosts: Option<String>,
279
280 #[arg(
282 long,
283 global = true,
284 action = ArgAction::SetTrue,
285 help_heading = "MITM"
286 )]
287 pub mitm_ws: bool,
288
289 #[arg(long, global = true, value_name = "BYTES", help_heading = "MITM")]
291 pub mitm_max_body_bytes: Option<usize>,
292
293 #[arg(
295 long,
296 global = true,
297 action = ArgAction::SetTrue,
298 help_heading = "MITM"
299 )]
300 pub mitm_no_media_bodies: bool,
301
302 #[arg(
304 long,
305 global = true,
306 action = ArgAction::SetTrue,
307 help_heading = "MITM"
308 )]
309 pub mitm_redact_secrets: bool,
310}
311
312#[derive(Debug, Subcommand)]
313pub enum Commands {
314 Doctor {
319 #[arg(long, action = ArgAction::SetTrue)]
320 offline: bool,
321 #[arg(long, action = ArgAction::SetTrue)]
322 quick: bool,
323 #[arg(long, action = ArgAction::SetTrue)]
324 fix: bool,
325 },
326 Commands,
330 Schema {
333 #[arg(long = "cmd", value_name = "CMD")]
335 cmd: Option<String>,
336 #[arg(value_name = "CMD")]
338 cmd_positional: Option<String>,
339 },
340 Version,
342 Locale,
344 Goto {
346 #[arg(value_hint = ValueHint::Url)]
347 url: String,
348 #[arg(long)]
350 init_script: Option<String>,
351 #[arg(long, value_enum, num_args = 0..=1, default_missing_value = "accept")]
353 handle_before_unload: Option<BeforeUnloadAction>,
354 #[arg(long)]
356 navigation_timeout_ms: Option<u64>,
357 },
358 View {
360 #[arg(long = "detailed", action = ArgAction::SetTrue)]
366 verbose: bool,
367 #[arg(long, value_hint = ValueHint::FilePath)]
368 path: Option<std::path::PathBuf>,
369 #[arg(long, action = ArgAction::SetTrue)]
371 allow_empty: bool,
372 },
373 Press {
375 target: String,
376 #[arg(long, action = ArgAction::SetTrue)]
377 dblclick: bool,
378 #[arg(long, action = ArgAction::SetTrue)]
380 include_snapshot: bool,
381 },
382 ClickAt {
384 #[arg(long)]
385 x: f64,
386 #[arg(long)]
387 y: f64,
388 #[arg(long, action = ArgAction::SetTrue)]
389 dblclick: bool,
390 #[arg(long, action = ArgAction::SetTrue)]
392 include_snapshot: bool,
393 },
394 Write {
396 target: String,
397 value: String,
398 #[arg(long, action = ArgAction::SetTrue)]
400 include_snapshot: bool,
401 },
402 Keys {
404 key: String,
405 #[arg(long, action = ArgAction::SetTrue)]
407 include_snapshot: bool,
408 },
409 Type {
411 text: String,
413 #[arg(long)]
415 target: Option<String>,
416 #[arg(long, action = ArgAction::SetTrue)]
417 clear: bool,
418 #[arg(long)]
420 submit: Option<String>,
421 #[arg(long, action = ArgAction::SetTrue)]
423 focus_only: bool,
424 },
425 Wait {
427 #[arg(long, default_value_t = 0)]
428 ms: u64,
429 #[arg(long = "text", action = clap::ArgAction::Append)]
431 text: Vec<String>,
432 #[arg(long)]
433 selector: Option<String>,
434 #[arg(long)]
436 state: Option<String>,
437 #[arg(long)]
439 wait_timeout_ms: Option<u64>,
440 #[arg(long, action = ArgAction::SetTrue)]
442 include_snapshot: bool,
443 },
444 Hover {
446 target: String,
447 #[arg(long, action = ArgAction::SetTrue)]
449 include_snapshot: bool,
450 },
451 Drag {
453 #[arg(long)]
454 from: String,
455 #[arg(long)]
456 to: String,
457 #[arg(long, action = ArgAction::SetTrue)]
459 include_snapshot: bool,
460 },
461 FillForm {
463 #[arg(long = "fields-json", value_name = "JSON")]
465 fields_json: String,
466 #[arg(long, action = ArgAction::SetTrue)]
468 include_snapshot: bool,
469 },
470 Upload {
472 target: String,
473 #[arg(value_hint = ValueHint::FilePath)]
474 path: std::path::PathBuf,
475 #[arg(long, action = ArgAction::SetTrue)]
477 include_snapshot: bool,
478 },
479 Back,
481 Forward,
483 Reload {
485 #[arg(long, action = ArgAction::SetTrue)]
486 ignore_cache: bool,
487 #[arg(long)]
489 init_script: Option<String>,
490 #[arg(long, value_enum, num_args = 0..=1, default_missing_value = "accept")]
492 handle_before_unload: Option<BeforeUnloadAction>,
493 },
494 Eval {
496 expression: String,
498 #[arg(long)]
500 args: Option<String>,
501 #[arg(long)]
503 dialog_action: Option<String>,
504 #[arg(long, value_hint = ValueHint::FilePath)]
506 file_path: Option<std::path::PathBuf>,
507 #[arg(long)]
509 service_worker_id: Option<String>,
510 },
511 Grab {
513 #[arg(long, value_hint = ValueHint::FilePath)]
514 path: Option<std::path::PathBuf>,
515 #[arg(long, value_enum, default_value_t = GrabFormat::Png)]
516 format: GrabFormat,
517 #[arg(long, action = ArgAction::SetTrue)]
518 full_page: bool,
519 #[arg(long)]
520 quality: Option<i32>,
521 #[arg(long)]
523 element: Option<String>,
524 },
525 PrintPdf {
527 #[arg(long, value_hint = ValueHint::FilePath)]
529 path: Option<std::path::PathBuf>,
530 #[arg(long)]
532 url: Option<String>,
533 },
534 Monitor {
536 #[command(subcommand)]
537 action: MonitorAction,
538 },
539 Run {
541 #[arg(long, value_hint = ValueHint::FilePath)]
542 script: std::path::PathBuf,
543 },
544 Exec {
546 #[arg(trailing_var_arg = true)]
549 args: Vec<String>,
550 },
551 Extract {
553 target: String,
555 #[arg(long)]
556 attr: Option<String>,
557 #[arg(long, action = ArgAction::SetTrue)]
559 llm: bool,
560 #[arg(long)]
562 question: Option<String>,
563 #[arg(long, value_hint = ValueHint::FilePath)]
565 schema_json: Option<std::path::PathBuf>,
566 },
567 Text { target: String },
569 Scroll {
571 #[arg(long)]
573 target: Option<String>,
574 #[arg(long, default_value_t = 0.0)]
575 delta_x: f64,
576 #[arg(long, default_value_t = 0.0)]
577 delta_y: f64,
578 },
579 Cookie {
581 #[command(subcommand)]
582 action: CookieAction,
583 },
584 Attr { target: String, name: String },
586 Assert {
588 #[command(subcommand)]
589 kind: AssertKind,
590 },
591 Console {
593 #[command(subcommand)]
594 action: ConsoleAction,
595 },
596 Net {
598 #[command(subcommand)]
599 action: NetAction,
600 },
601 Page {
603 #[command(subcommand)]
604 action: Option<PageAction>,
605 },
606 Dialog {
608 #[command(subcommand)]
609 action: DialogAction,
610 },
611 Scrape {
613 #[arg(value_hint = ValueHint::Url)]
614 url: String,
615 #[arg(long = "format", alias = "formats", value_delimiter = ',', num_args = 1.., default_value = "text")]
617 format: Vec<String>,
618 #[arg(long, default_value = "browser")]
620 engine: String,
621 #[arg(long, action = ArgAction::SetTrue)]
623 only_main_content: bool,
624 #[arg(long)]
626 webhook_url: Option<String>,
627 },
628 BatchScrape {
630 #[arg(long, value_hint = ValueHint::FilePath)]
631 urls_file: std::path::PathBuf,
632 #[arg(long = "format", alias = "formats", default_value = "text")]
633 format: String,
634 #[arg(long, default_value_t = 0)]
636 concurrency: usize,
637 #[arg(long, default_value = "http")]
639 engine: String,
640 },
641 Crawl {
643 #[arg(value_hint = ValueHint::Url)]
644 url: String,
645 #[arg(long, alias = "max-pages", default_value_t = 20)]
646 limit: usize,
647 #[arg(long, default_value_t = 2)]
648 max_depth: usize,
649 #[arg(long = "format", alias = "formats", default_value = "text")]
650 format: String,
651 #[arg(long, default_value_t = true)]
653 same_host: bool,
654 #[arg(long, default_value = "http")]
656 engine: String,
657 },
658 Map {
660 #[arg(value_hint = ValueHint::Url)]
661 url: String,
662 #[arg(long, default_value_t = 50)]
663 limit: usize,
664 #[arg(long, default_value_t = 2)]
665 max_depth: usize,
666 },
667 Search {
669 query: String,
670 #[arg(long, default_value_t = 10)]
671 limit: usize,
672 },
673 Parse {
675 #[arg(value_hint = ValueHint::FilePath)]
676 path: std::path::PathBuf,
677 #[arg(long, action = ArgAction::SetTrue)]
679 redact_pii: bool,
680 },
681 Qr {
683 #[command(subcommand)]
684 action: QrAction,
685 },
686 FindPaths {
688 pattern: Option<String>,
690 #[arg(num_args = 0..)]
692 paths: Vec<String>,
693 #[arg(long)]
695 extension: Option<String>,
696 #[arg(long, action = ArgAction::SetTrue)]
698 hidden: bool,
699 #[arg(long, action = ArgAction::SetTrue)]
701 no_ignore: bool,
702 #[arg(long)]
704 max_depth: Option<usize>,
705 #[arg(long = "type")]
707 entry_type: Option<String>,
708 #[arg(long, default_value_t = 10000)]
710 limit: usize,
711 #[arg(long)]
713 glob: Option<String>,
714 },
715 SgScan {
717 #[arg(num_args = 0..)]
719 paths: Vec<String>,
720 #[arg(long, default_value_t = 500)]
722 limit: usize,
723 },
724 SgRewrite {
726 #[arg(num_args = 0..)]
728 paths: Vec<String>,
729 #[arg(long, action = ArgAction::SetTrue)]
731 apply: bool,
732 },
733 SheetWrite {
735 #[arg(value_hint = ValueHint::FilePath)]
737 input: std::path::PathBuf,
738 #[arg(long, short = 'o', value_hint = ValueHint::FilePath)]
740 out: std::path::PathBuf,
741 #[arg(long, default_value = "Sheet1")]
743 sheet: String,
744 },
745 Mitm {
747 #[command(subcommand)]
748 action: MitmAction,
749 },
750 Workflow {
752 #[command(subcommand)]
753 action: WorkflowAction,
754 },
755 Config {
757 #[command(subcommand)]
758 action: ConfigAction,
759 },
760 Emulate {
762 #[arg(long)]
763 user_agent: Option<String>,
764 #[arg(long)]
765 locale: Option<String>,
766 #[arg(long)]
767 timezone: Option<String>,
768 #[arg(long, action = ArgAction::SetTrue)]
769 offline: bool,
770 #[arg(long)]
771 latitude: Option<f64>,
772 #[arg(long)]
773 longitude: Option<f64>,
774 #[arg(long)]
775 media: Option<String>,
776 #[arg(long)]
778 network_conditions: Option<String>,
779 #[arg(long)]
781 cpu_throttling_rate: Option<f64>,
782 #[arg(long)]
784 color_scheme: Option<String>,
785 #[arg(long)]
787 extra_headers: Option<String>,
788 #[arg(long)]
790 viewport: Option<String>,
791 },
792 Resize {
794 #[arg(long)]
795 width: i32,
796 #[arg(long)]
797 height: i32,
798 #[arg(long, default_value_t = 1.0)]
799 scale: f64,
800 #[arg(long, action = ArgAction::SetTrue)]
801 mobile: bool,
802 },
803 Perf {
805 #[command(subcommand)]
806 action: PerfAction,
807 },
808 Lighthouse {
810 #[arg(value_hint = ValueHint::Url)]
811 url: String,
812 #[arg(long, value_hint = ValueHint::DirPath)]
813 out_dir: Option<std::path::PathBuf>,
814 #[arg(long, default_value = "desktop")]
815 device: String,
816 #[arg(long, default_value = "navigation")]
818 mode: String,
819 #[arg(long, value_hint = ValueHint::FilePath)]
820 lighthouse_path: Option<std::path::PathBuf>,
821 },
822 Screencast {
824 #[command(subcommand)]
825 action: ScreencastAction,
826 },
827 Heap {
829 #[command(subcommand)]
830 action: HeapAction,
831 },
832 Extension {
834 #[command(subcommand)]
835 action: ExtensionAction,
836 },
837 Devtools3p {
839 #[command(subcommand)]
840 action: Devtools3pAction,
841 },
842 Webmcp {
844 #[command(subcommand)]
845 action: WebmcpAction,
846 },
847 Completions {
849 #[arg(value_enum)]
850 shell: CompletionShell,
851 },
852 Man {
854 #[arg(long, value_name = "PATH", value_hint = ValueHint::FilePath)]
856 out: Option<std::path::PathBuf>,
857 },
858}
859
860#[derive(Debug, Clone, Subcommand)]
861pub enum PerfAction {
862 Start {
863 #[arg(long, value_hint = ValueHint::FilePath)]
864 path: Option<std::path::PathBuf>,
865 #[arg(long, action = ArgAction::SetTrue)]
866 reload: bool,
867 #[arg(long, action = ArgAction::SetTrue)]
869 auto_stop: bool,
870 },
871 Stop {
872 #[arg(long, value_hint = ValueHint::FilePath)]
873 path: Option<std::path::PathBuf>,
874 },
875 Insight {
876 #[arg(long)]
878 name: Option<String>,
879 #[arg(long)]
881 insight_set_id: Option<String>,
882 #[arg(long)]
884 insight_name: Option<String>,
885 },
886}
887
888#[derive(Debug, Clone, Subcommand)]
889pub enum ScreencastAction {
890 Start {
891 #[arg(long, value_hint = ValueHint::FilePath)]
892 path: Option<std::path::PathBuf>,
893 },
894 Stop {
895 #[arg(long, value_hint = ValueHint::FilePath)]
897 path: Option<std::path::PathBuf>,
898 },
899}
900
901#[derive(Debug, Clone, Subcommand)]
902pub enum HeapAction {
903 Take {
904 #[arg(long, value_hint = ValueHint::FilePath)]
905 path: std::path::PathBuf,
906 },
907 Close {
908 #[arg(long, value_hint = ValueHint::FilePath)]
909 path: std::path::PathBuf,
910 },
911 Compare {
912 #[arg(long, value_hint = ValueHint::FilePath)]
913 base: std::path::PathBuf,
914 #[arg(long, value_hint = ValueHint::FilePath)]
915 current: std::path::PathBuf,
916 #[arg(long)]
918 class_index: Option<u64>,
919 },
920 Summary {
921 #[arg(long, value_hint = ValueHint::FilePath)]
922 path: std::path::PathBuf,
923 },
924 Details {
925 #[arg(long, value_hint = ValueHint::FilePath)]
926 path: std::path::PathBuf,
927 #[arg(long)]
928 filter_name: Option<String>,
929 #[arg(long)]
930 page_idx: Option<usize>,
931 #[arg(long)]
932 page_size: Option<usize>,
933 },
934 ClassNodes {
935 #[arg(long, value_hint = ValueHint::FilePath)]
936 path: std::path::PathBuf,
937 #[arg(long)]
938 id: u64,
939 #[arg(long)]
940 filter_name: Option<String>,
941 #[arg(long)]
942 page_idx: Option<usize>,
943 #[arg(long)]
944 page_size: Option<usize>,
945 },
946 Dominators {
947 #[arg(long, value_hint = ValueHint::FilePath)]
948 path: std::path::PathBuf,
949 #[arg(long)]
950 node: u64,
951 },
952 DupStrings {
953 #[arg(long, value_hint = ValueHint::FilePath)]
954 path: std::path::PathBuf,
955 #[arg(long)]
956 page_idx: Option<usize>,
957 #[arg(long)]
958 page_size: Option<usize>,
959 },
960 Edges {
961 #[arg(long, value_hint = ValueHint::FilePath)]
962 path: std::path::PathBuf,
963 #[arg(long)]
964 node: u64,
965 #[arg(long)]
966 page_idx: Option<usize>,
967 #[arg(long)]
968 page_size: Option<usize>,
969 },
970 Retainers {
971 #[arg(long, value_hint = ValueHint::FilePath)]
972 path: std::path::PathBuf,
973 #[arg(long)]
974 node: u64,
975 #[arg(long)]
976 page_idx: Option<usize>,
977 #[arg(long)]
978 page_size: Option<usize>,
979 },
980 Paths {
981 #[arg(long, value_hint = ValueHint::FilePath)]
982 path: std::path::PathBuf,
983 #[arg(long)]
984 node: u64,
985 #[arg(long, default_value_t = 8)]
986 max_depth: u64,
987 #[arg(long)]
988 max_nodes: Option<u64>,
989 #[arg(long)]
990 max_siblings: Option<u64>,
991 },
992 ObjectDetails {
994 #[arg(long, value_hint = ValueHint::FilePath)]
995 path: std::path::PathBuf,
996 #[arg(long)]
997 node: u64,
998 },
999}
1000
1001#[derive(Debug, Clone, Subcommand)]
1002pub enum ExtensionAction {
1003 List,
1004 Install {
1005 path: std::path::PathBuf,
1006 },
1007 Reload {
1008 id: String,
1009 #[arg(long, value_hint = ValueHint::FilePath)]
1011 path: Option<std::path::PathBuf>,
1012 },
1013 Trigger {
1014 id: String,
1015 #[arg(long, value_hint = ValueHint::FilePath)]
1017 path: Option<std::path::PathBuf>,
1018 },
1019 Uninstall {
1020 id: String,
1021 },
1022}
1023
1024#[derive(Debug, Clone, Subcommand)]
1025pub enum Devtools3pAction {
1026 List {
1027 #[arg(long)]
1029 url: Option<String>,
1030 },
1031 Exec {
1032 name: String,
1033 #[arg(long)]
1034 params: Option<String>,
1035 #[arg(long)]
1036 url: Option<String>,
1037 },
1038}
1039
1040#[derive(Debug, Clone, Subcommand)]
1041pub enum WebmcpAction {
1042 List {
1043 #[arg(long)]
1044 url: Option<String>,
1045 },
1046 Exec {
1047 name: String,
1048 #[arg(long)]
1049 input: Option<String>,
1050 #[arg(long)]
1051 url: Option<String>,
1052 },
1053}
1054
1055#[derive(Debug, Clone, Copy, ValueEnum)]
1056pub enum CompletionShell {
1057 Bash,
1058 Zsh,
1059 Fish,
1060 Elvish,
1061 Powershell,
1062}
1063
1064#[derive(Debug, Clone, Subcommand)]
1065pub enum QrAction {
1066 Encode {
1068 #[arg(long)]
1069 text: String,
1070 #[arg(long, default_value = "png")]
1072 format: String,
1073 #[arg(long, value_hint = ValueHint::FilePath)]
1074 path: Option<std::path::PathBuf>,
1075 },
1076 Decode {
1078 #[arg(long, value_hint = ValueHint::FilePath)]
1079 path: std::path::PathBuf,
1080 },
1081}
1082
1083#[derive(Debug, Clone, Subcommand)]
1084pub enum MonitorAction {
1085 Check {
1087 #[arg(long)]
1089 url: String,
1090 #[arg(long, value_hint = ValueHint::FilePath)]
1092 baseline: std::path::PathBuf,
1093 #[arg(long, action = ArgAction::SetTrue)]
1095 write_baseline: bool,
1096 #[arg(long, default_value = "http")]
1098 engine: String,
1099 },
1100}
1101
1102#[derive(Debug, Clone, Subcommand)]
1103pub enum PageAction {
1104 Info,
1106 List,
1108 New {
1110 #[arg(long)]
1111 url: Option<String>,
1112 #[arg(long, action = ArgAction::SetTrue)]
1114 background: bool,
1115 #[arg(long, num_args = 0..=1, default_missing_value = "default-isolated")]
1117 isolated_context: Option<String>,
1118 },
1119 Select {
1121 #[arg(value_name = "INDEX")]
1122 index: Option<usize>,
1123 #[arg(long = "page-id")]
1125 page_id: Option<usize>,
1126 #[arg(long, default_value_t = true)]
1128 bring_to_front: bool,
1129 },
1130 Close {
1132 #[arg(long)]
1133 index: Option<usize>,
1134 #[arg(long = "page-id")]
1136 page_id: Option<usize>,
1137 },
1138 TabId,
1140}
1141
1142#[derive(Debug, Clone, Subcommand)]
1143pub enum CookieAction {
1144 List {
1146 #[arg(long)]
1147 url: Option<String>,
1148 },
1149 Set {
1151 #[arg(long = "cookies-json", value_name = "JSON")]
1154 cookies_json: String,
1155 },
1156 Clear,
1158}
1159
1160#[derive(Debug, Clone, Copy, ValueEnum, Default)]
1161pub enum GrabFormat {
1162 #[default]
1163 Png,
1164 Jpeg,
1165 Webp,
1166}
1167
1168#[derive(Debug, Clone, Copy, ValueEnum)]
1170pub enum BeforeUnloadAction {
1171 Accept,
1172 Dismiss,
1173}
1174
1175impl BeforeUnloadAction {
1176 pub fn as_str(self) -> &'static str {
1178 match self {
1179 Self::Accept => "accept",
1180 Self::Dismiss => "dismiss",
1181 }
1182 }
1183}
1184
1185
1186#[derive(Debug, Clone, Subcommand)]
1187pub enum AssertKind {
1188 Url {
1189 value: String,
1190 #[arg(long, action = ArgAction::SetTrue)]
1191 contains: bool,
1192 },
1193 Text {
1194 value: String,
1195 #[arg(long)]
1196 target: Option<String>,
1197 },
1198 Console {
1199 #[arg(long, default_value = "error")]
1200 level: String,
1201 #[arg(long, default_value_t = 0)]
1202 max: u64,
1203 },
1204 ConsoleEmpty,
1206 ConsoleNoMatch {
1208 #[arg(long)]
1209 pattern: String,
1210 },
1211}
1212
1213#[derive(Debug, Clone, Subcommand)]
1214pub enum ConsoleAction {
1215 List {
1216 #[arg(long)]
1218 page_idx: Option<usize>,
1219 #[arg(long)]
1221 page_size: Option<usize>,
1222 #[arg(long)]
1224 types: Option<String>,
1225 #[arg(long, action = ArgAction::SetTrue)]
1227 include_preserved: bool,
1228 #[arg(long)]
1230 service_worker_id: Option<String>,
1231 },
1232 Get {
1233 id: usize,
1234 },
1235 Clear,
1236 Dump {
1237 #[arg(long, value_hint = ValueHint::FilePath)]
1238 path: std::path::PathBuf,
1239 },
1240}
1241
1242#[derive(Debug, Clone, Subcommand)]
1243pub enum NetAction {
1244 List {
1245 #[arg(long)]
1247 page_idx: Option<usize>,
1248 #[arg(long)]
1250 page_size: Option<usize>,
1251 #[arg(long)]
1253 resource_types: Option<String>,
1254 #[arg(long, action = ArgAction::SetTrue)]
1256 include_preserved: bool,
1257 },
1258 Get {
1259 id: String,
1261 #[arg(long, value_hint = ValueHint::FilePath)]
1262 request_path: Option<std::path::PathBuf>,
1263 #[arg(long, value_hint = ValueHint::FilePath)]
1264 response_path: Option<std::path::PathBuf>,
1265 },
1266}
1267
1268#[derive(Debug, Clone, Subcommand)]
1269pub enum DialogAction {
1270 Accept {
1271 #[arg(long)]
1272 text: Option<String>,
1273 #[arg(long, action = ArgAction::SetTrue)]
1275 if_present: bool,
1276 },
1277 Dismiss {
1278 #[arg(long, action = ArgAction::SetTrue)]
1280 if_present: bool,
1281 },
1282}
1283
1284#[derive(Debug, Clone, Subcommand)]
1285pub enum MitmAction {
1286 Status,
1288 List {
1290 #[arg(long)]
1291 host: Option<String>,
1292 #[arg(long, default_value_t = 100)]
1293 limit: usize,
1294 },
1295 Get { id: u64 },
1297 Har {
1299 #[arg(long, value_hint = ValueHint::FilePath)]
1300 out: std::path::PathBuf,
1301 },
1302 Export {
1304 #[arg(long, default_value = "json")]
1305 format: String,
1306 #[arg(long, value_hint = ValueHint::FilePath)]
1307 out: std::path::PathBuf,
1308 },
1309 Domains,
1311 Apis {
1313 #[arg(long)]
1314 kind: Option<String>,
1315 },
1316 InitCa,
1318 Start {
1320 #[arg(long, default_value_t = 30)]
1322 seconds: u64,
1323 },
1324 CaptureUrl {
1326 #[arg(value_hint = ValueHint::Url)]
1328 url: String,
1329 #[arg(long, default_value_t = 30)]
1331 seconds: u64,
1332 #[arg(long, value_hint = ValueHint::FilePath)]
1334 har: Option<std::path::PathBuf>,
1335 #[arg(long)]
1337 hosts: Option<String>,
1338 },
1339 Graphql {
1341 #[arg(long, default_value_t = 100)]
1342 limit: usize,
1343 },
1344 Ws {
1346 #[command(subcommand)]
1347 action: MitmWsAction,
1348 },
1349 Block {
1351 #[arg(long)]
1352 host: Option<String>,
1353 #[arg(long)]
1354 path: Option<String>,
1355 },
1356 Allow {
1358 #[arg(long)]
1359 host: String,
1360 },
1361 Redact {
1363 #[arg(long, default_value_t = true)]
1365 secrets: bool,
1366 },
1367}
1368
1369#[derive(Debug, Clone, Subcommand)]
1370pub enum MitmWsAction {
1371 List {
1373 #[arg(long, default_value_t = 100)]
1374 limit: usize,
1375 },
1376 Get { id: u64 },
1378}
1379
1380#[derive(Debug, Clone, Subcommand)]
1381pub enum WorkflowAction {
1382 Run {
1384 #[arg(long, value_hint = ValueHint::FilePath)]
1385 manifest: std::path::PathBuf,
1386 #[arg(long, value_hint = ValueHint::FilePath)]
1387 journal: Option<std::path::PathBuf>,
1388 },
1389 Resume {
1391 #[arg(long, value_hint = ValueHint::FilePath)]
1392 manifest: std::path::PathBuf,
1393 #[arg(long, value_hint = ValueHint::FilePath)]
1394 journal: Option<std::path::PathBuf>,
1395 },
1396 Status {
1398 #[arg(long, value_hint = ValueHint::FilePath)]
1399 journal: Option<std::path::PathBuf>,
1400 #[arg(long)]
1401 name: Option<String>,
1402 },
1403}
1404
1405#[derive(Debug, Clone, Subcommand)]
1406pub enum ConfigAction {
1407 Path,
1409 Init,
1411 Show,
1413 Set { key: String, value: String },
1415 Get { key: Option<String> },
1417 ListKeys,
1419}