summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorRosyid Haryadi <rosyid_haryadi@protonmail.com>2025-03-15 20:24:23 +0700
committerRosyid Haryadi <rosyid_haryadi@protonmail.com>2025-03-15 20:24:23 +0700
commitc8e2b39ee7d3d650f741ce90d3f93fa8b97faa07 (patch)
treebd846e8e9228dec7d2e63b54f956f1db2783de76 /src/main.rs
parentb7f0a8a2b2961c04f022e8177c34dfb9d6ac7cc6 (diff)
feat: init subcommand
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs18
1 files changed, 16 insertions, 2 deletions
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<PathBuf>,
+ },
}
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