Init commit

This commit is contained in:
Antonin Ruan
2026-02-19 14:46:58 +01:00
commit f600a89f5b
12 changed files with 993 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
use crate::subcommands::{
init::InitSubcommand,
test::TestSubcommand,
hash_object::HashObjectSubcommand,
};
mod hash_object;
mod init;
mod test;
pub type CmdResult = Result<String, String>;
#[derive(clap::Parser, Debug)]
pub enum SubcommandType {
/// Init a Git repository
Init(InitSubcommand),
HashObject(HashObjectSubcommand),
Test(TestSubcommand),
}
pub trait Subcommand {
fn run(&self) -> CmdResult;
}
impl Subcommand for SubcommandType {
fn run(&self) -> CmdResult {
match self {
Self::Init(cmd) => cmd.run(),
Self::HashObject(cmd) => cmd.run(),
Self::Test(cmd) => cmd.run(),
}
}
}