Skip to content

Commit

Permalink
feat: working on init
Browse files Browse the repository at this point in the history
  • Loading branch information
matzxrr committed Jan 22, 2024
1 parent 2836afb commit e8334ab
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
4 changes: 2 additions & 2 deletions dotme-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -33,7 +33,7 @@ fn main() {
let args = Cli::parse();
match args.command {
Commands::Init => {
init::init();
let _ = init::init();
}
Commands::Clone => {
todo!()
Expand Down
28 changes: 26 additions & 2 deletions dotme-core/src/cmd/init.rs
Original file line number Diff line number Diff line change
@@ -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<dyn Error>> {
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(())
}

0 comments on commit e8334ab

Please sign in to comment.