async_git/porcelain/
show.rs1use crate::errors::{Result, Error};
2use crate::plumbing::{Commit, Oid, ParsedObject, Repository};
3
4#[derive(Debug, StructOpt)]
5pub struct ShowOptions {
6 objects: Vec<Oid>,
8}
9
10pub async fn show_cmd(options: ShowOptions) -> Result<()> {
11 let object_ids = options.objects;
12 let repo = match Repository::find().await? {
13 Some(path) => Repository::open(path).await?,
14 None => return Err(Error::CurrentDirectoryNotInRepository),
15 };
16
17 println!("repo: {:?}", repo.path);
18 for id in object_ids {
19 let object = repo.get_object(id);
20 let parsed_object = object.peel().await?;
21
22 match &parsed_object {
23 ParsedObject::Commit(commit) => show_commit(commit),
24 _ => (),
25 }
26 }
27
28 Ok(())
29}
30
31fn show_commit(commit: &Commit) {
32 println!("commit: {:?}", commit);
33}