diff --git a/dotme-cli/src/main.rs b/dotme-cli/src/main.rs index 4863ee7..476e6a9 100644 --- a/dotme-cli/src/main.rs +++ b/dotme-cli/src/main.rs @@ -18,7 +18,7 @@ struct Cli { #[derive(Debug, Subcommand)] enum Commands { - #[command(about = "Setup new dotfile repo")] + #[command(about = "Setup a new dotfile repo")] Init, #[command(about = "Clone and install your dotfiles")] Clone, @@ -33,7 +33,7 @@ fn main() { let args = Cli::parse(); match args.command { Commands::Init => { - init::init(); + let _ = init::init(); } Commands::Clone => { todo!() diff --git a/dotme-core/src/cmd/init.rs b/dotme-core/src/cmd/init.rs index 6275c85..a03ee04 100644 --- a/dotme-core/src/cmd/init.rs +++ b/dotme-core/src/cmd/init.rs @@ -1,3 +1,27 @@ -pub fn init() { - println!("Running Init"); +use std::thread; +use std::time::Duration; +use std::{error::Error, path::PathBuf}; + +use dialoguer::{theme::ColorfulTheme, Input}; + +use console::Term; + +pub fn init() -> Result<(), Box> { + let term = Term::stdout(); + term.write_line("\n\nSetting up a new dotfile repo\n")?; + + let input: String = Input::with_theme(&ColorfulTheme::default()) + .with_prompt("Repo location") + .default("~/.cfg".to_string()) + .validate_with(validate_repo_location) + .interact_text()?; + + term.write_line(&format!("found {}", input))?; + + thread::sleep(Duration::from_millis(2000)); + Ok(()) +} + +fn validate_repo_location(input: &String) -> Result<(), &str> { + Ok(()) }