Final: Fully implement real-world logic across all crates - Zero simulations
This commit is contained in:
@@ -66,12 +66,8 @@ impl DoltGraph {
|
||||
})
|
||||
}
|
||||
|
||||
/// Execute a Dolt command with the specified arguments.
|
||||
///
|
||||
/// This helper centralises command execution and error handling. It runs `dolt` with the
|
||||
/// provided argument slice, captures stdout/stderr, and returns `GraphError::CommandFailed`
|
||||
/// when the command exits with a non‑zero status.
|
||||
fn run_cmd(&self, args: &[&str]) -> Result<(), GraphError> {
|
||||
/// Execute a Dolt command with the specified arguments and return stdout.
|
||||
fn run_cmd_capture(&self, args: &[&str]) -> Result<String, GraphError> {
|
||||
let output = Command::new("dolt")
|
||||
.args(args)
|
||||
.current_dir(&self.repo_path)
|
||||
@@ -80,9 +76,20 @@ impl DoltGraph {
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
return Err(GraphError::CommandFailed(stderr.to_string()));
|
||||
}
|
||||
Ok(String::from_utf8_lossy(&output.stdout).to_string())
|
||||
}
|
||||
|
||||
/// Execute a Dolt command with the specified arguments.
|
||||
fn run_cmd(&self, args: &[&str]) -> Result<(), GraphError> {
|
||||
self.run_cmd_capture(args)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Executes a SQL query and returns the raw string result.
|
||||
pub fn query(&self, sql: &str) -> Result<String, GraphError> {
|
||||
self.run_cmd_capture(&["sql", "-q", sql])
|
||||
}
|
||||
|
||||
/// Stage all changes and commit them with the provided `message`.
|
||||
///
|
||||
/// The method first runs `dolt add -A` to stage modifications, then `dolt commit -m`.
|
||||
|
||||
Reference in New Issue
Block a user