Init commit
This commit is contained in:
@@ -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(),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user