pub trait CommandOptions {
type Output;
// Required methods
fn git_args(&self) -> Vec<&str>;
fn parse_output(&self, out: &str) -> Result<Self::Output, Error>;
// Provided method
fn run(&self, repo: &Repository) -> Result<Self::Output, Error> { ... }
}
Expand description
Trait implemented by all command option struct (CommitOptions
, PushOptions
, etc.)
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn run(&self, repo: &Repository) -> Result<Self::Output, Error>
fn run(&self, repo: &Repository) -> Result<Self::Output, Error>
Run the command in the given git repository. Calling git and parsing and return the output of the command, if any.
If the git command returns error a GitError is returned.
use mhgit::{Repository, CommandOptions};
use mhgit::commands::AddOptions;
let repo = Repository::new();
let _ = AddOptions::new()
.all(true)
.run(&repo)?;