diff --git a/src/git.rs b/src/git.rs new file mode 100644 index 0000000..a081758 --- /dev/null +++ b/src/git.rs @@ -0,0 +1,33 @@ +use clap::Subcommand; +use std::process::Command; + +#[derive(Subcommand)] +pub enum GitCommand { + Create { + #[arg()] + name: String + }, + + List, + + Delete { + #[arg()] + name: String + } +} + +pub fn handle_git(cmd: &GitCommand) { + match cmd { + GitCommand::Create { name } => { + let path = format!("git@breadpi:~/store/{}", name); + let git_create = Command::new("ssh") + .args([path]) + .spawn() + .expect("Could not create remote repo!"); + } + + _ => { + println!("oopsies") + } + } +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 148bf18..41e49c1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,7 @@ +mod git; + use clap::{Parser, Subcommand}; +use crate::git::{handle_git, GitCommand}; #[derive(Subcommand)] enum Command { @@ -8,20 +11,6 @@ enum Command { } } -#[derive(Subcommand)] -enum GitCommand { - Create { - #[arg()] - name: String - }, - - List, - - Delete { - #[arg()] - name: String - } -} #[derive(Parser)] struct Cli { @@ -38,16 +27,3 @@ fn main() { } } } - - -fn handle_git(cmd: &GitCommand) { - match cmd { - GitCommand::Create { name } => { - println!("{}", name); - } - - _ => { - println!("oopsies") - } - } -} \ No newline at end of file