diff --git a/src/args.rs b/src/args.rs index 6bfc79a..c5f4962 100644 --- a/src/args.rs +++ b/src/args.rs @@ -50,7 +50,7 @@ pub enum RuntipiMainCommand { Update(UpdateCommand), /// Manage your apps App(AppCommand), - /// Reset your runtipi password + /// Initiate a password reset for the admin user ResetPassword, /// Debug your runtipi instance Debug, diff --git a/src/commands/reset_password.rs b/src/commands/reset_password.rs index 9216c10..89368f2 100644 --- a/src/commands/reset_password.rs +++ b/src/commands/reset_password.rs @@ -1,10 +1,25 @@ -use std::{fs::File, path::PathBuf}; -use std::env; use colored::Colorize; +use std::env; +use std::{fs::File, path::PathBuf}; pub fn run() { let root_folder: PathBuf = env::current_dir().expect("Unable to get current directory"); - let mut _reset_password_request = File::create(root_folder.join("state").join("password-change-request")); - print!("{}", "✓ ".green()); - println!("Password reset request created. Head back to the dashboard to set a new password.") -} \ No newline at end of file + let reset_password_request = File::create(root_folder.join("state").join("password-change-request")); + + match reset_password_request { + Ok(_) => { + println!( + "{} Password reset request created. Head back to the dashboard to set a new password.", + "✓".green() + ) + } + Err(_) => { + println!( + "{} Unable to create password reset request. You can manually create an empty file at {} to initiate a password reset.", + "✗".red(), + root_folder.join("state").join("password-change-request").to_str().unwrap() + ); + return; + } + } +} diff --git a/src/main.rs b/src/main.rs index 34e10a1..2d625e8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,7 +12,7 @@ use crate::commands::update::UpdateArgs; fn main() { let args = RuntipiArgs::parse(); - println!("{}", "Welcome to Runtipi CLI ✨".green()); + println!("{}", "Welcome to Runtipi CLI ✨\n".green()); match args.command { args::RuntipiMainCommand::Start(args) => {