Build a DaemonRequest from parsed CLI args. Resolve a relative path to an absolute one using the CLI process's CWD. The daemon retains its own startup CWD, so relative paths sent to it would resolve against the wrong directory.
(path: &str)
| 439 | /// The daemon retains its own startup CWD, so relative paths sent to it would |
| 440 | /// resolve against the wrong directory. |
| 441 | fn absolutize_path(path: &str) -> Result<String> { |
| 442 | let p = std::path::Path::new(path); |
| 443 | if p.is_absolute() { |
| 444 | Ok(path.to_string()) |
| 445 | } else { |
| 446 | // Fail loudly if the CWD can't be resolved: silently falling back to an |
| 447 | // empty path would send a bogus relative path to the daemon, which would |
| 448 | // resolve it against the daemon's (different) startup CWD. |
| 449 | let cwd = std::env::current_dir() |
| 450 | .map_err(|e| anyhow::anyhow!("Failed to resolve CLI working directory to absolutize path '{path}': {e}"))?; |
| 451 | Ok(cwd.join(p).to_string_lossy().to_string()) |
| 452 | } |
| 453 | } |
| 454 | |
| 455 | fn parse_json_value(v: &str) -> serde_json::Value { |
| 456 | if v.eq_ignore_ascii_case("true") { |