1#![allow(missing_docs)]
5
6use clap::{ArgAction, Args, Parser, Subcommand, ValueEnum, ValueHint};
7
8#[derive(Debug, Parser)]
10#[command(
11 name = "browser-automation-cli",
12 version,
13 author,
14 about = "One-shot browser automation CLI (Chrome CDP). BORN, EXECUTE, FINALIZE, DIE.",
15 long_about = None,
16 propagate_version = true,
17 after_help = "Examples:\n \
18browser-automation-cli doctor --json\n \
19browser-automation-cli goto https://example.com --json\n \
20browser-automation-cli schema run\n \
21browser-automation-cli run --script steps.ndjson --json-steps\n \
22browser-automation-cli config path\n\n\
23Exit codes follow sysexits-style mapping (2 usage, 69 unavailable, 70 software, 124 timeout).\n\
24Config is XDG-only (config set); product settings do not read process environment variables."
25)]
26pub struct Cli {
27 #[command(flatten)]
29 pub globals: GlobalOpts,
30
31 #[command(subcommand)]
33 pub command: Commands,
34}
35
36#[derive(Debug, Clone, Args)]
40pub struct GlobalOpts {
41 #[arg(long, global = true, action = ArgAction::SetTrue, help_heading = "Output")]
43 pub json: bool,
44
45 #[arg(
47 long = "json-steps",
48 global = true,
49 action = ArgAction::SetTrue,
50 help_heading = "Output"
51 )]
52 pub json_steps: bool,
53
54 #[arg(
56 short = 'q',
57 long = "quiet",
58 global = true,
59 action = ArgAction::SetTrue,
60 help_heading = "Output"
61 )]
62 pub quiet: bool,
63
64 #[arg(
66 short = 'v',
67 long = "verbose",
68 global = true,
69 action = ArgAction::SetTrue,
70 help_heading = "Output"
71 )]
72 pub verbose: bool,
73
74 #[arg(
76 long = "debug",
77 global = true,
78 action = ArgAction::SetTrue,
79 help_heading = "Output"
80 )]
81 pub debug: bool,
82
83 #[arg(
85 long,
86 global = true,
87 default_value_t = 0,
88 value_name = "SECS",
89 help_heading = "Timeouts"
90 )]
91 pub timeout: u64,
92
93 #[arg(
95 long,
96 global = true,
97 default_value_t = 0,
98 value_name = "SECS",
99 help_heading = "Timeouts"
100 )]
101 pub step_timeout: u64,
102
103 #[arg(
105 long,
106 global = true,
107 action = ArgAction::SetTrue,
108 help_heading = "Browser"
109 )]
110 pub headed: bool,
111
112 #[arg(
114 long,
115 global = true,
116 value_name = "DIR",
117 value_hint = ValueHint::DirPath,
118 help_heading = "Browser"
119 )]
120 pub artifacts_dir: Option<std::path::PathBuf>,
121
122 #[arg(long, global = true, value_name = "LANG", help_heading = "Output")]
124 pub lang: Option<String>,
125
126 #[arg(
128 long,
129 global = true,
130 action = ArgAction::SetTrue,
131 help_heading = "Browser"
132 )]
133 pub capture_console: bool,
134
135 #[arg(
137 long,
138 global = true,
139 action = ArgAction::SetTrue,
140 help_heading = "Browser"
141 )]
142 pub capture_network: bool,
143
144 #[arg(
146 long,
147 global = true,
148 action = ArgAction::SetTrue,
149 help_heading = "Robots"
150 )]
151 pub ignore_robots: bool,
152
153 #[arg(
155 long,
156 global = true,
157 action = ArgAction::SetTrue,
158 help_heading = "Robots"
159 )]
160 pub i_accept_robots_risk: bool,
161
162 #[arg(
164 long,
165 global = true,
166 action = ArgAction::SetTrue,
167 help_heading = "Categories"
168 )]
169 pub category_memory: bool,
170
171 #[arg(
173 long,
174 global = true,
175 action = ArgAction::SetTrue,
176 help_heading = "Categories"
177 )]
178 pub category_extensions: bool,
179
180 #[arg(
182 long,
183 global = true,
184 action = ArgAction::SetTrue,
185 help_heading = "Categories"
186 )]
187 pub category_third_party: bool,
188
189 #[arg(
191 long,
192 global = true,
193 action = ArgAction::SetTrue,
194 help_heading = "Categories"
195 )]
196 pub category_webmcp: bool,
197
198 #[arg(
200 long,
201 global = true,
202 action = ArgAction::SetTrue,
203 help_heading = "Categories"
204 )]
205 pub experimental_screencast: bool,
206
207 #[arg(
209 long,
210 global = true,
211 action = ArgAction::SetTrue,
212 help_heading = "Categories"
213 )]
214 pub experimental_vision: bool,
215
216 #[arg(
218 long,
219 global = true,
220 action = ArgAction::SetTrue,
221 help_heading = "MITM"
222 )]
223 pub mitm: bool,
224
225 #[arg(
227 long,
228 global = true,
229 value_name = "DIR",
230 value_hint = ValueHint::DirPath,
231 help_heading = "MITM"
232 )]
233 pub mitm_ca_dir: Option<std::path::PathBuf>,
234
235 #[arg(
237 long,
238 global = true,
239 value_name = "FILE",
240 value_hint = ValueHint::FilePath,
241 help_heading = "MITM"
242 )]
243 pub mitm_har: Option<std::path::PathBuf>,
244
245 #[arg(long, global = true, value_name = "HOSTS", help_heading = "MITM")]
247 pub mitm_hosts: Option<String>,
248
249 #[arg(
251 long,
252 global = true,
253 action = ArgAction::SetTrue,
254 help_heading = "MITM"
255 )]
256 pub mitm_ws: bool,
257
258 #[arg(long, global = true, value_name = "BYTES", help_heading = "MITM")]
260 pub mitm_max_body_bytes: Option<usize>,
261
262 #[arg(
264 long,
265 global = true,
266 action = ArgAction::SetTrue,
267 help_heading = "MITM"
268 )]
269 pub mitm_no_media_bodies: bool,
270
271 #[arg(
273 long,
274 global = true,
275 action = ArgAction::SetTrue,
276 help_heading = "MITM"
277 )]
278 pub mitm_redact_secrets: bool,
279}
280
281#[derive(Debug, Subcommand)]
282pub enum Commands {
283 Doctor {
285 #[arg(long, action = ArgAction::SetTrue)]
286 offline: bool,
287 #[arg(long, action = ArgAction::SetTrue)]
288 quick: bool,
289 #[arg(long, action = ArgAction::SetTrue)]
290 fix: bool,
291 #[arg(long, action = ArgAction::SetTrue)]
292 json: bool,
293 },
294 Commands {
296 #[arg(long, action = ArgAction::SetTrue)]
297 json: bool,
298 },
299 Schema {
302 #[arg(long = "cmd", value_name = "CMD")]
304 cmd: Option<String>,
305 #[arg(value_name = "CMD")]
307 cmd_positional: Option<String>,
308 },
309 Version,
311 Goto {
313 #[arg(value_hint = ValueHint::Url)]
314 url: String,
315 #[arg(long)]
317 init_script: Option<String>,
318 #[arg(long, value_enum, num_args = 0..=1, default_missing_value = "accept")]
320 handle_before_unload: Option<BeforeUnloadAction>,
321 #[arg(long)]
323 navigation_timeout_ms: Option<u64>,
324 },
325 View {
327 #[arg(long, action = ArgAction::SetTrue)]
328 verbose: bool,
329 #[arg(long, value_hint = ValueHint::FilePath)]
330 path: Option<std::path::PathBuf>,
331 #[arg(long, action = ArgAction::SetTrue)]
333 allow_empty: bool,
334 },
335 Press {
337 target: String,
338 #[arg(long, action = ArgAction::SetTrue)]
339 dblclick: bool,
340 #[arg(long, action = ArgAction::SetTrue)]
342 include_snapshot: bool,
343 },
344 ClickAt {
346 #[arg(long)]
347 x: f64,
348 #[arg(long)]
349 y: f64,
350 #[arg(long, action = ArgAction::SetTrue)]
351 dblclick: bool,
352 #[arg(long, action = ArgAction::SetTrue)]
354 include_snapshot: bool,
355 },
356 Write {
358 target: String,
359 value: String,
360 #[arg(long, action = ArgAction::SetTrue)]
362 include_snapshot: bool,
363 },
364 Keys {
366 key: String,
367 #[arg(long, action = ArgAction::SetTrue)]
369 include_snapshot: bool,
370 },
371 Type {
373 text: String,
375 #[arg(long)]
377 target: Option<String>,
378 #[arg(long, action = ArgAction::SetTrue)]
379 clear: bool,
380 #[arg(long)]
382 submit: Option<String>,
383 #[arg(long, action = ArgAction::SetTrue)]
385 focus_only: bool,
386 },
387 Wait {
389 #[arg(long, default_value_t = 0)]
390 ms: u64,
391 #[arg(long = "text", action = clap::ArgAction::Append)]
393 text: Vec<String>,
394 #[arg(long)]
395 selector: Option<String>,
396 #[arg(long)]
398 state: Option<String>,
399 #[arg(long)]
401 wait_timeout_ms: Option<u64>,
402 #[arg(long, action = ArgAction::SetTrue)]
404 include_snapshot: bool,
405 },
406 Hover {
408 target: String,
409 #[arg(long, action = ArgAction::SetTrue)]
411 include_snapshot: bool,
412 },
413 Drag {
415 #[arg(long)]
416 from: String,
417 #[arg(long)]
418 to: String,
419 #[arg(long, action = ArgAction::SetTrue)]
421 include_snapshot: bool,
422 },
423 FillForm {
425 #[arg(long)]
426 json: String,
427 #[arg(long, action = ArgAction::SetTrue)]
429 include_snapshot: bool,
430 },
431 Upload {
433 target: String,
434 #[arg(value_hint = ValueHint::FilePath)]
435 path: std::path::PathBuf,
436 #[arg(long, action = ArgAction::SetTrue)]
438 include_snapshot: bool,
439 },
440 Back,
442 Forward,
444 Reload {
446 #[arg(long, action = ArgAction::SetTrue)]
447 ignore_cache: bool,
448 #[arg(long)]
450 init_script: Option<String>,
451 #[arg(long, value_enum, num_args = 0..=1, default_missing_value = "accept")]
453 handle_before_unload: Option<BeforeUnloadAction>,
454 },
455 Eval {
457 expression: String,
459 #[arg(long)]
461 args: Option<String>,
462 #[arg(long)]
464 dialog_action: Option<String>,
465 #[arg(long, value_hint = ValueHint::FilePath)]
467 file_path: Option<std::path::PathBuf>,
468 #[arg(long)]
470 service_worker_id: Option<String>,
471 },
472 Grab {
474 #[arg(long, value_hint = ValueHint::FilePath)]
475 path: Option<std::path::PathBuf>,
476 #[arg(long, value_enum, default_value_t = GrabFormat::Png)]
477 format: GrabFormat,
478 #[arg(long, action = ArgAction::SetTrue)]
479 full_page: bool,
480 #[arg(long)]
481 quality: Option<i32>,
482 #[arg(long)]
484 element: Option<String>,
485 },
486 PrintPdf {
488 #[arg(long, value_hint = ValueHint::FilePath)]
490 path: Option<std::path::PathBuf>,
491 #[arg(long)]
493 url: Option<String>,
494 },
495 Monitor {
497 #[command(subcommand)]
498 action: MonitorAction,
499 },
500 Run {
502 #[arg(long, value_hint = ValueHint::FilePath)]
503 script: std::path::PathBuf,
504 },
505 Exec {
507 #[arg(trailing_var_arg = true)]
510 args: Vec<String>,
511 },
512 Extract {
514 target: String,
516 #[arg(long)]
517 attr: Option<String>,
518 #[arg(long, action = ArgAction::SetTrue)]
520 llm: bool,
521 #[arg(long)]
523 question: Option<String>,
524 #[arg(long, value_hint = ValueHint::FilePath)]
526 schema_json: Option<std::path::PathBuf>,
527 },
528 Text { target: String },
530 Scroll {
532 #[arg(long)]
534 target: Option<String>,
535 #[arg(long, default_value_t = 0.0)]
536 delta_x: f64,
537 #[arg(long, default_value_t = 0.0)]
538 delta_y: f64,
539 },
540 Cookie {
542 #[command(subcommand)]
543 action: CookieAction,
544 },
545 Attr { target: String, name: String },
547 Assert {
549 #[command(subcommand)]
550 kind: AssertKind,
551 },
552 Console {
554 #[command(subcommand)]
555 action: ConsoleAction,
556 },
557 Net {
559 #[command(subcommand)]
560 action: NetAction,
561 },
562 Page {
564 #[command(subcommand)]
565 action: Option<PageAction>,
566 },
567 Dialog {
569 #[command(subcommand)]
570 action: DialogAction,
571 },
572 Scrape {
574 #[arg(value_hint = ValueHint::Url)]
575 url: String,
576 #[arg(long = "format", alias = "formats", value_delimiter = ',', num_args = 1.., default_value = "text")]
578 format: Vec<String>,
579 #[arg(long, default_value = "browser")]
581 engine: String,
582 #[arg(long, action = ArgAction::SetTrue)]
584 only_main_content: bool,
585 #[arg(long)]
587 webhook_url: Option<String>,
588 },
589 BatchScrape {
591 #[arg(long, value_hint = ValueHint::FilePath)]
592 urls_file: std::path::PathBuf,
593 #[arg(long = "format", alias = "formats", default_value = "text")]
594 format: String,
595 #[arg(long, default_value_t = 2)]
596 concurrency: usize,
597 #[arg(long, default_value = "http")]
599 engine: String,
600 },
601 Crawl {
603 #[arg(value_hint = ValueHint::Url)]
604 url: String,
605 #[arg(long, alias = "max-pages", default_value_t = 20)]
606 limit: usize,
607 #[arg(long, default_value_t = 2)]
608 max_depth: usize,
609 #[arg(long = "format", alias = "formats", default_value = "text")]
610 format: String,
611 #[arg(long, default_value_t = true)]
613 same_host: bool,
614 #[arg(long, default_value = "http")]
616 engine: String,
617 },
618 Map {
620 #[arg(value_hint = ValueHint::Url)]
621 url: String,
622 #[arg(long, default_value_t = 50)]
623 limit: usize,
624 #[arg(long, default_value_t = 2)]
625 max_depth: usize,
626 },
627 Search {
629 query: String,
630 #[arg(long, default_value_t = 10)]
631 limit: usize,
632 },
633 Parse {
635 #[arg(value_hint = ValueHint::FilePath)]
636 path: std::path::PathBuf,
637 #[arg(long, action = ArgAction::SetTrue)]
639 redact_pii: bool,
640 },
641 Qr {
643 #[command(subcommand)]
644 action: QrAction,
645 },
646 FindPaths {
648 pattern: Option<String>,
650 #[arg(num_args = 0..)]
652 paths: Vec<String>,
653 #[arg(long)]
655 extension: Option<String>,
656 #[arg(long, action = ArgAction::SetTrue)]
658 hidden: bool,
659 #[arg(long, action = ArgAction::SetTrue)]
661 no_ignore: bool,
662 #[arg(long)]
664 max_depth: Option<usize>,
665 #[arg(long = "type")]
667 entry_type: Option<String>,
668 #[arg(long, default_value_t = 10000)]
670 limit: usize,
671 #[arg(long)]
673 glob: Option<String>,
674 },
675 SgScan {
677 #[arg(num_args = 0..)]
679 paths: Vec<String>,
680 #[arg(long, default_value_t = 500)]
682 limit: usize,
683 },
684 SgRewrite {
686 #[arg(num_args = 0..)]
688 paths: Vec<String>,
689 #[arg(long, action = ArgAction::SetTrue)]
691 apply: bool,
692 },
693 SheetWrite {
695 #[arg(value_hint = ValueHint::FilePath)]
697 input: std::path::PathBuf,
698 #[arg(long, short = 'o', value_hint = ValueHint::FilePath)]
700 out: std::path::PathBuf,
701 #[arg(long, default_value = "Sheet1")]
703 sheet: String,
704 },
705 Mitm {
707 #[command(subcommand)]
708 action: MitmAction,
709 },
710 Workflow {
712 #[command(subcommand)]
713 action: WorkflowAction,
714 },
715 Config {
717 #[command(subcommand)]
718 action: ConfigAction,
719 },
720 Emulate {
722 #[arg(long)]
723 user_agent: Option<String>,
724 #[arg(long)]
725 locale: Option<String>,
726 #[arg(long)]
727 timezone: Option<String>,
728 #[arg(long, action = ArgAction::SetTrue)]
729 offline: bool,
730 #[arg(long)]
731 latitude: Option<f64>,
732 #[arg(long)]
733 longitude: Option<f64>,
734 #[arg(long)]
735 media: Option<String>,
736 #[arg(long)]
738 network_conditions: Option<String>,
739 #[arg(long)]
741 cpu_throttling_rate: Option<f64>,
742 #[arg(long)]
744 color_scheme: Option<String>,
745 #[arg(long)]
747 extra_headers: Option<String>,
748 #[arg(long)]
750 viewport: Option<String>,
751 },
752 Resize {
754 #[arg(long)]
755 width: i32,
756 #[arg(long)]
757 height: i32,
758 #[arg(long, default_value_t = 1.0)]
759 scale: f64,
760 #[arg(long, action = ArgAction::SetTrue)]
761 mobile: bool,
762 },
763 Perf {
765 #[command(subcommand)]
766 action: PerfAction,
767 },
768 Lighthouse {
770 #[arg(value_hint = ValueHint::Url)]
771 url: String,
772 #[arg(long, value_hint = ValueHint::DirPath)]
773 out_dir: Option<std::path::PathBuf>,
774 #[arg(long, default_value = "desktop")]
775 device: String,
776 #[arg(long, default_value = "navigation")]
778 mode: String,
779 #[arg(long, value_hint = ValueHint::FilePath)]
780 lighthouse_path: Option<std::path::PathBuf>,
781 },
782 Screencast {
784 #[command(subcommand)]
785 action: ScreencastAction,
786 },
787 Heap {
789 #[command(subcommand)]
790 action: HeapAction,
791 },
792 Extension {
794 #[command(subcommand)]
795 action: ExtensionAction,
796 },
797 Devtools3p {
799 #[command(subcommand)]
800 action: Devtools3pAction,
801 },
802 Webmcp {
804 #[command(subcommand)]
805 action: WebmcpAction,
806 },
807 Completions {
809 #[arg(value_enum)]
810 shell: CompletionShell,
811 },
812}
813
814#[derive(Debug, Clone, Subcommand)]
815pub enum PerfAction {
816 Start {
817 #[arg(long, value_hint = ValueHint::FilePath)]
818 path: Option<std::path::PathBuf>,
819 #[arg(long, action = ArgAction::SetTrue)]
820 reload: bool,
821 #[arg(long, action = ArgAction::SetTrue)]
823 auto_stop: bool,
824 },
825 Stop {
826 #[arg(long, value_hint = ValueHint::FilePath)]
827 path: Option<std::path::PathBuf>,
828 },
829 Insight {
830 #[arg(long)]
832 name: Option<String>,
833 #[arg(long)]
835 insight_set_id: Option<String>,
836 #[arg(long)]
838 insight_name: Option<String>,
839 },
840}
841
842#[derive(Debug, Clone, Subcommand)]
843pub enum ScreencastAction {
844 Start {
845 #[arg(long, value_hint = ValueHint::FilePath)]
846 path: Option<std::path::PathBuf>,
847 },
848 Stop {
849 #[arg(long, value_hint = ValueHint::FilePath)]
851 path: Option<std::path::PathBuf>,
852 },
853}
854
855#[derive(Debug, Clone, Subcommand)]
856pub enum HeapAction {
857 Take {
858 #[arg(long, value_hint = ValueHint::FilePath)]
859 path: std::path::PathBuf,
860 },
861 Close {
862 #[arg(long, value_hint = ValueHint::FilePath)]
863 path: std::path::PathBuf,
864 },
865 Compare {
866 #[arg(long, value_hint = ValueHint::FilePath)]
867 base: std::path::PathBuf,
868 #[arg(long, value_hint = ValueHint::FilePath)]
869 current: std::path::PathBuf,
870 #[arg(long)]
872 class_index: Option<u64>,
873 },
874 Summary {
875 #[arg(long, value_hint = ValueHint::FilePath)]
876 path: std::path::PathBuf,
877 },
878 Details {
879 #[arg(long, value_hint = ValueHint::FilePath)]
880 path: std::path::PathBuf,
881 #[arg(long)]
882 filter_name: Option<String>,
883 #[arg(long)]
884 page_idx: Option<usize>,
885 #[arg(long)]
886 page_size: Option<usize>,
887 },
888 ClassNodes {
889 #[arg(long, value_hint = ValueHint::FilePath)]
890 path: std::path::PathBuf,
891 #[arg(long)]
892 id: u64,
893 #[arg(long)]
894 filter_name: Option<String>,
895 #[arg(long)]
896 page_idx: Option<usize>,
897 #[arg(long)]
898 page_size: Option<usize>,
899 },
900 Dominators {
901 #[arg(long, value_hint = ValueHint::FilePath)]
902 path: std::path::PathBuf,
903 #[arg(long)]
904 node: u64,
905 },
906 DupStrings {
907 #[arg(long, value_hint = ValueHint::FilePath)]
908 path: std::path::PathBuf,
909 #[arg(long)]
910 page_idx: Option<usize>,
911 #[arg(long)]
912 page_size: Option<usize>,
913 },
914 Edges {
915 #[arg(long, value_hint = ValueHint::FilePath)]
916 path: std::path::PathBuf,
917 #[arg(long)]
918 node: u64,
919 #[arg(long)]
920 page_idx: Option<usize>,
921 #[arg(long)]
922 page_size: Option<usize>,
923 },
924 Retainers {
925 #[arg(long, value_hint = ValueHint::FilePath)]
926 path: std::path::PathBuf,
927 #[arg(long)]
928 node: u64,
929 #[arg(long)]
930 page_idx: Option<usize>,
931 #[arg(long)]
932 page_size: Option<usize>,
933 },
934 Paths {
935 #[arg(long, value_hint = ValueHint::FilePath)]
936 path: std::path::PathBuf,
937 #[arg(long)]
938 node: u64,
939 #[arg(long, default_value_t = 8)]
940 max_depth: u64,
941 #[arg(long)]
942 max_nodes: Option<u64>,
943 #[arg(long)]
944 max_siblings: Option<u64>,
945 },
946 ObjectDetails {
948 #[arg(long, value_hint = ValueHint::FilePath)]
949 path: std::path::PathBuf,
950 #[arg(long)]
951 node: u64,
952 },
953}
954
955#[derive(Debug, Clone, Subcommand)]
956pub enum ExtensionAction {
957 List,
958 Install {
959 path: std::path::PathBuf,
960 },
961 Reload {
962 id: String,
963 #[arg(long, value_hint = ValueHint::FilePath)]
965 path: Option<std::path::PathBuf>,
966 },
967 Trigger {
968 id: String,
969 #[arg(long, value_hint = ValueHint::FilePath)]
971 path: Option<std::path::PathBuf>,
972 },
973 Uninstall {
974 id: String,
975 },
976}
977
978#[derive(Debug, Clone, Subcommand)]
979pub enum Devtools3pAction {
980 List {
981 #[arg(long)]
983 url: Option<String>,
984 },
985 Exec {
986 name: String,
987 #[arg(long)]
988 params: Option<String>,
989 #[arg(long)]
990 url: Option<String>,
991 },
992}
993
994#[derive(Debug, Clone, Subcommand)]
995pub enum WebmcpAction {
996 List {
997 #[arg(long)]
998 url: Option<String>,
999 },
1000 Exec {
1001 name: String,
1002 #[arg(long)]
1003 input: Option<String>,
1004 #[arg(long)]
1005 url: Option<String>,
1006 },
1007}
1008
1009#[derive(Debug, Clone, Copy, ValueEnum)]
1010pub enum CompletionShell {
1011 Bash,
1012 Zsh,
1013 Fish,
1014 Elvish,
1015 Powershell,
1016}
1017
1018#[derive(Debug, Clone, Subcommand)]
1019pub enum QrAction {
1020 Encode {
1022 #[arg(long)]
1023 text: String,
1024 #[arg(long, default_value = "png")]
1026 format: String,
1027 #[arg(long, value_hint = ValueHint::FilePath)]
1028 path: Option<std::path::PathBuf>,
1029 },
1030 Decode {
1032 #[arg(long, value_hint = ValueHint::FilePath)]
1033 path: std::path::PathBuf,
1034 },
1035}
1036
1037#[derive(Debug, Clone, Subcommand)]
1038pub enum MonitorAction {
1039 Check {
1041 #[arg(long)]
1043 url: String,
1044 #[arg(long, value_hint = ValueHint::FilePath)]
1046 baseline: std::path::PathBuf,
1047 #[arg(long, action = ArgAction::SetTrue)]
1049 write_baseline: bool,
1050 #[arg(long, default_value = "http")]
1052 engine: String,
1053 },
1054}
1055
1056#[derive(Debug, Clone, Subcommand)]
1057pub enum PageAction {
1058 Info,
1060 List,
1062 New {
1064 #[arg(long)]
1065 url: Option<String>,
1066 #[arg(long, action = ArgAction::SetTrue)]
1068 background: bool,
1069 #[arg(long, num_args = 0..=1, default_missing_value = "default-isolated")]
1071 isolated_context: Option<String>,
1072 },
1073 Select {
1075 #[arg(value_name = "INDEX")]
1076 index: Option<usize>,
1077 #[arg(long = "page-id")]
1079 page_id: Option<usize>,
1080 #[arg(long, default_value_t = true)]
1082 bring_to_front: bool,
1083 },
1084 Close {
1086 #[arg(long)]
1087 index: Option<usize>,
1088 #[arg(long = "page-id")]
1090 page_id: Option<usize>,
1091 },
1092 TabId,
1094}
1095
1096#[derive(Debug, Clone, Subcommand)]
1097pub enum CookieAction {
1098 List {
1100 #[arg(long)]
1101 url: Option<String>,
1102 },
1103 Set {
1105 #[arg(long)]
1107 json: String,
1108 },
1109 Clear,
1111}
1112
1113#[derive(Debug, Clone, Copy, ValueEnum, Default)]
1114pub enum GrabFormat {
1115 #[default]
1116 Png,
1117 Jpeg,
1118 Webp,
1119}
1120
1121#[derive(Debug, Clone, Copy, ValueEnum)]
1123pub enum BeforeUnloadAction {
1124 Accept,
1125 Dismiss,
1126}
1127
1128impl BeforeUnloadAction {
1129 pub fn as_str(self) -> &'static str {
1131 match self {
1132 Self::Accept => "accept",
1133 Self::Dismiss => "dismiss",
1134 }
1135 }
1136}
1137
1138
1139#[derive(Debug, Clone, Subcommand)]
1140pub enum AssertKind {
1141 Url {
1142 value: String,
1143 #[arg(long, action = ArgAction::SetTrue)]
1144 contains: bool,
1145 },
1146 Text {
1147 value: String,
1148 #[arg(long)]
1149 target: Option<String>,
1150 },
1151 Console {
1152 #[arg(long, default_value = "error")]
1153 level: String,
1154 #[arg(long, default_value_t = 0)]
1155 max: u64,
1156 },
1157 ConsoleEmpty,
1159 ConsoleNoMatch {
1161 #[arg(long)]
1162 pattern: String,
1163 },
1164}
1165
1166#[derive(Debug, Clone, Subcommand)]
1167pub enum ConsoleAction {
1168 List {
1169 #[arg(long)]
1171 page_idx: Option<usize>,
1172 #[arg(long)]
1174 page_size: Option<usize>,
1175 #[arg(long)]
1177 types: Option<String>,
1178 #[arg(long, action = ArgAction::SetTrue)]
1180 include_preserved: bool,
1181 #[arg(long)]
1183 service_worker_id: Option<String>,
1184 },
1185 Get {
1186 id: usize,
1187 },
1188 Clear,
1189 Dump {
1190 #[arg(long, value_hint = ValueHint::FilePath)]
1191 path: std::path::PathBuf,
1192 },
1193}
1194
1195#[derive(Debug, Clone, Subcommand)]
1196pub enum NetAction {
1197 List {
1198 #[arg(long)]
1200 page_idx: Option<usize>,
1201 #[arg(long)]
1203 page_size: Option<usize>,
1204 #[arg(long)]
1206 resource_types: Option<String>,
1207 #[arg(long, action = ArgAction::SetTrue)]
1209 include_preserved: bool,
1210 },
1211 Get {
1212 id: String,
1214 #[arg(long, value_hint = ValueHint::FilePath)]
1215 request_path: Option<std::path::PathBuf>,
1216 #[arg(long, value_hint = ValueHint::FilePath)]
1217 response_path: Option<std::path::PathBuf>,
1218 },
1219}
1220
1221#[derive(Debug, Clone, Subcommand)]
1222pub enum DialogAction {
1223 Accept {
1224 #[arg(long)]
1225 text: Option<String>,
1226 #[arg(long, action = ArgAction::SetTrue)]
1228 if_present: bool,
1229 },
1230 Dismiss {
1231 #[arg(long, action = ArgAction::SetTrue)]
1233 if_present: bool,
1234 },
1235}
1236
1237#[derive(Debug, Clone, Subcommand)]
1238pub enum MitmAction {
1239 Status,
1241 List {
1243 #[arg(long)]
1244 host: Option<String>,
1245 #[arg(long, default_value_t = 100)]
1246 limit: usize,
1247 },
1248 Get { id: u64 },
1250 Har {
1252 #[arg(long, value_hint = ValueHint::FilePath)]
1253 out: std::path::PathBuf,
1254 },
1255 Export {
1257 #[arg(long, default_value = "json")]
1258 format: String,
1259 #[arg(long, value_hint = ValueHint::FilePath)]
1260 out: std::path::PathBuf,
1261 },
1262 Domains,
1264 Apis {
1266 #[arg(long)]
1267 kind: Option<String>,
1268 },
1269 InitCa,
1271 Start {
1273 #[arg(long, default_value_t = 30)]
1275 seconds: u64,
1276 },
1277 CaptureUrl {
1279 #[arg(value_hint = ValueHint::Url)]
1281 url: String,
1282 #[arg(long, default_value_t = 30)]
1284 seconds: u64,
1285 #[arg(long, value_hint = ValueHint::FilePath)]
1287 har: Option<std::path::PathBuf>,
1288 #[arg(long)]
1290 hosts: Option<String>,
1291 },
1292 Graphql {
1294 #[arg(long, default_value_t = 100)]
1295 limit: usize,
1296 },
1297 Ws {
1299 #[command(subcommand)]
1300 action: MitmWsAction,
1301 },
1302 Block {
1304 #[arg(long)]
1305 host: Option<String>,
1306 #[arg(long)]
1307 path: Option<String>,
1308 },
1309 Allow {
1311 #[arg(long)]
1312 host: String,
1313 },
1314 Redact {
1316 #[arg(long, default_value_t = true)]
1318 secrets: bool,
1319 },
1320}
1321
1322#[derive(Debug, Clone, Subcommand)]
1323pub enum MitmWsAction {
1324 List {
1326 #[arg(long, default_value_t = 100)]
1327 limit: usize,
1328 },
1329 Get { id: u64 },
1331}
1332
1333#[derive(Debug, Clone, Subcommand)]
1334pub enum WorkflowAction {
1335 Run {
1337 #[arg(long, value_hint = ValueHint::FilePath)]
1338 manifest: std::path::PathBuf,
1339 #[arg(long, value_hint = ValueHint::FilePath)]
1340 journal: Option<std::path::PathBuf>,
1341 },
1342 Resume {
1344 #[arg(long, value_hint = ValueHint::FilePath)]
1345 manifest: std::path::PathBuf,
1346 #[arg(long, value_hint = ValueHint::FilePath)]
1347 journal: Option<std::path::PathBuf>,
1348 },
1349 Status {
1351 #[arg(long, value_hint = ValueHint::FilePath)]
1352 journal: Option<std::path::PathBuf>,
1353 #[arg(long)]
1354 name: Option<String>,
1355 },
1356}
1357
1358#[derive(Debug, Clone, Subcommand)]
1359pub enum ConfigAction {
1360 Path,
1362 Init,
1364 Show,
1366 Set { key: String, value: String },
1368 Get { key: Option<String> },
1370 ListKeys,
1372}