From c8e2b39ee7d3d650f741ce90d3f93fa8b97faa07 Mon Sep 17 00:00:00 2001 From: Rosyid Haryadi Date: Sat, 15 Mar 2025 20:24:23 +0700 Subject: feat: init subcommand --- src/main.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 1827e66..8958192 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,9 @@ mod core; mod utilities; +use std::path::PathBuf; use clap::{Parser, Subcommand}; +use crate::core::GitRepository; #[derive(Parser)] #[command(version, about, long_about = None)] @@ -12,13 +14,25 @@ struct Cli { #[derive(Subcommand)] enum Command { - Init, + Init { + path: Option, + }, } fn main() { let cli = Cli::parse(); match &cli.command { - Command::Init => { todo!() } + Command::Init { path} => { + let mut p = PathBuf::new(); + if let Some(path) = path.clone() { + p = path.clone(); + } else { + if let Ok(path) = std::env::current_dir() { + p = path; + } + } + GitRepository::create_new_repo(p); + } } } \ No newline at end of file -- cgit v1.2.3-70-g09d2