async-git 0.0.0-squat-name

Pure-rust async implementation of git built on tokio
Documentation
use crate::errors::{Result, Error};
use crate::plumbing::{Commit, Oid, ParsedObject, Repository};

#[derive(Debug, StructOpt)]
pub struct ShowOptions {
    /// The names of objects to show (defaults to HEAD).
    objects: Vec<Oid>,
}

pub async fn show_cmd(options: ShowOptions) -> Result<()> {
    let object_ids = options.objects;
    let repo = match Repository::find().await? {
        Some(path) => Repository::open(path).await?,
        None => return Err(Error::CurrentDirectoryNotInRepository),
    };

    println!("repo: {:?}", repo.path);
    for id in object_ids {
        let object = repo.get_object(id);
        let parsed_object = object.peel().await?;

        match &parsed_object {
            ParsedObject::Commit(commit) => show_commit(commit),
            _ => (),
        }
    }

    Ok(())
}

fn show_commit(commit: &Commit) {
    println!("commit: {:?}", commit);
}