use crate::errors::{Result, Error};
use crate::plumbing::{Commit, Oid, ParsedObject, Repository};
#[derive(Debug, StructOpt)]
pub struct ShowOptions {
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);
}