Trait CommandOptions

Source
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§

Source

fn git_args(&self) -> Vec<&str>

Return a vector of the arguments passed to git.

The vector contains at least one element, which is the name of the subcommand.

Source

fn parse_output(&self, out: &str) -> Result<Self::Output, Error>

Parse the captured stdout into an appropriate rust type.

Provided Methods§

Source

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)?;

Implementors§