summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorRosyid Haryadi <rosyid_haryadi@protonmail.com>2025-03-18 15:32:50 +0700
committerRosyid Haryadi <rosyid_haryadi@protonmail.com>2025-03-18 15:32:50 +0700
commita8cf3b2757dee028e86f7cc6848b741c46dd933a (patch)
treed263a03b8f0089c6d4ef84fbb3700ccfc1ba8e6d /src/main.rs
parenta173c17a4b45f30a0190050beb96684cf03ab5f0 (diff)
upd: implementing cat-file & add readme
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index 66891c4..a82a6e8 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -5,6 +5,7 @@ mod object;
use crate::repository::GitRepository;
use clap::{Parser, Subcommand};
use std::path::PathBuf;
+use crate::object::{GitObject, GitObjectType};
#[derive(Parser)]
#[command(version, about, long_about = None)]
@@ -69,6 +70,19 @@ fn main() {
}
GitRepository::create_new_repo(p);
}
+ Command::CatFile { object_type, sha} => {
+ // todo detect root otomatis
+ // temporary
+ let repo = GitRepository::from_dir(PathBuf::from("."));
+ let object_type = match &object_type[..] {
+ "blob" => GitObjectType::Blob,
+ "commit" => GitObjectType::Commit,
+ "tag" => GitObjectType::Tag,
+ "tree" => GitObjectType::Tree,
+ _ => GitObjectType::Undefined
+ };
+ repo.cat_file(object_type, sha.as_str());
+ }
_ => {}
}
} \ No newline at end of file