MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / resolve_at_file

Function resolve_at_file

src/tool_command/args.rs:720–735  ·  view source on GitHub ↗

Read a value from disk when it starts with `@`. The leading `@` is stripped; the rest is treated as a path (relative to cwd). Plain values pass through unchanged. To pass a literal `@` as the first character, use `--args` instead.

(raw: &str, read_stdin: &mut impl FnMut() -> Result<String>)

Source from the content-addressed store, hash-verified

718/// pass through unchanged. To pass a literal `@` as the first character, use
719/// `--args` instead.
720fn resolve_at_file(raw: &str, read_stdin: &mut impl FnMut() -> Result<String>) -> Result<String> {
721 if let Some(path) = raw.strip_prefix('@') {
722 if path == "-" {
723 return read_stdin();
724 }
725 let buf = PathBuf::from(path);
726 std::fs::read_to_string(&buf).map_err(|e| TraceDecayError::Config {
727 message: format!(
728 "failed to read @{path}: {e} — the path is resolved relative to the current \
729 directory; for a literal value that begins with `@`, use --args instead"
730 ),
731 })
732 } else {
733 Ok(raw.to_string())
734 }
735}

Callers 3

bind_positionalsFunction · 0.85
resolve_args_payloadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected