pub struct CommandCapture { /* private fields */ }Expand description
Accumulates an invocation, then writes it into a RunManifest (claim) and/or
reconstructs an argv for re-execution.
Implementations§
Source§impl CommandCapture
impl CommandCapture
Sourcepub fn new(subcommand: impl Into<String>) -> CommandCapture
pub fn new(subcommand: impl Into<String>) -> CommandCapture
Start capturing an invocation of subcommand (e.g. "variants").
Sourcepub fn input(
&mut self,
flag: &str,
path: &Path,
) -> Result<&mut CommandCapture, Error>
pub fn input( &mut self, flag: &str, path: &Path, ) -> Result<&mut CommandCapture, Error>
A content-addressed input operand; hashes the file and records it.
Sourcepub fn output(
&mut self,
flag: &str,
path: &Path,
) -> Result<&mut CommandCapture, Error>
pub fn output( &mut self, flag: &str, path: &Path, ) -> Result<&mut CommandCapture, Error>
A content-addressed output operand; hashes the file and records it.
Sourcepub fn input_hashed(
&mut self,
flag: &str,
path: &str,
blake3: &str,
) -> &mut CommandCapture
pub fn input_hashed( &mut self, flag: &str, path: &str, blake3: &str, ) -> &mut CommandCapture
Input operand with a precomputed hash (when the caller already hashed it, and in
tests). path is recorded into inputs[] for humans / verify to re-hash.
Sourcepub fn output_hashed(
&mut self,
flag: &str,
path: &str,
blake3: &str,
) -> &mut CommandCapture
pub fn output_hashed( &mut self, flag: &str, path: &str, blake3: &str, ) -> &mut CommandCapture
Output operand with a precomputed hash.
Sourcepub fn opt(&mut self, flag: &str, value: impl ToString) -> &mut CommandCapture
pub fn opt(&mut self, flag: &str, value: impl ToString) -> &mut CommandCapture
An option with a value, e.g. ("--max-depth", 1000).
Sourcepub fn flag(&mut self, flag: &str) -> &mut CommandCapture
pub fn flag(&mut self, flag: &str) -> &mut CommandCapture
A bare flag, e.g. "--enforce".
Sourcepub fn flag_if(&mut self, cond: bool, flag: &str) -> &mut CommandCapture
pub fn flag_if(&mut self, cond: bool, flag: &str) -> &mut CommandCapture
Record flag only when cond (so a false boolean leaves no trace).
Sourcepub fn record_into(self, m: &mut RunManifest)
pub fn record_into(self, m: &mut RunManifest)
Write the capture into a manifest’s claim: the command recipe, the derived
inputs[]/outputs[], the discrete params (mechanical flag→key projection), and
the inferred mode. Call before finalize(). Measurement fields remain the
caller’s responsibility (recorded separately, relocated by finalize).
Sourcepub fn argv_from_command(
command: &str,
locate_input: &dyn Fn(&str) -> Option<String>,
temp_output: &dyn Fn(&str) -> String,
) -> Result<Vec<String>, String>
pub fn argv_from_command( command: &str, locate_input: &dyn Fn(&str) -> Option<String>, temp_output: &dyn Fn(&str) -> String, ) -> Result<Vec<String>, String>
Reconstruct an argv from a recorded command: substitute each @in:<h> with the
located input path and each @out:<h> with a caller-supplied temp path. Errors
(naming the hash) if an input cannot be located.