MCPcopy Create free account
hub / github.com/aeroxy/chrome-devtools-cli / build_request

Function build_request

src/lib.rs:542–735  ·  view source on GitHub ↗
(cli: &Cli)

Source from the content-addressed store, hash-verified

540}
541
542fn build_request(cli: &Cli) -> Result<DaemonRequest> {
543 // Resolve relative file paths to absolute so the daemon (which retains its
544 // own startup CWD) resolves them correctly.
545 let absolutize = |p: &Option<String>| -> Result<Option<String>> {
546 match p {
547 None => Ok(None),
548 Some(s) => Ok(Some(absolutize_path(s)?)),
549 }
550 };
551
552 let (command, args) = match &cli.command {
553 Commands::ListPages => ("list-pages", json!({})),
554 Commands::Navigate {
555 url,
556 back,
557 forward,
558 reload,
559 extra_headers,
560 viewport,
561 device_scale_factor,
562 mobile,
563 geolocation,
564 accuracy,
565 clear_all,
566 output,
567 } => (
568 "navigate",
569 json!({
570 "url": url,
571 "back": back,
572 "forward": forward,
573 "reload": reload,
574 "extra_headers": extra_headers,
575 "viewport": viewport,
576 "device_scale_factor": device_scale_factor,
577 "mobile": mobile,
578 "geolocation": geolocation,
579 "accuracy": accuracy,
580 "clear_all": clear_all,
581 "output": absolutize(output)?
582 }),
583 ),
584 Commands::NewPage {
585 url,
586 viewport,
587 device_scale_factor,
588 mobile,
589 geolocation,
590 accuracy,
591 extra_headers,
592 } => (
593 "new-page",
594 json!({
595 "url": url,
596 "viewport": viewport,
597 "device_scale_factor": device_scale_factor,
598 "mobile": mobile,
599 "geolocation": geolocation,

Callers 1

runFunction · 0.85

Calls 2

absolutize_pathFunction · 0.85
output_formatMethod · 0.80

Tested by

no test coverage detected