diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/sessions.rs | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/sessions.rs b/src/sessions.rs index a13c6c7c1..0cc870a7e 100644 --- a/src/sessions.rs +++ b/src/sessions.rs @@ -1,6 +1,7 @@ use std::os::unix::fs::FileTypeExt; use std::time::SystemTime; use std::{fs, io, process}; +use suggestion::Suggest; use zellij_utils::{ consts::ZELLIJ_SOCK_DIR, envs, @@ -149,9 +150,19 @@ pub(crate) fn session_exists(name: &str) -> Result<bool, io::ErrorKind> { pub(crate) fn assert_session(name: &str) { match session_exists(name) { - Ok(result) if result => return, - Ok(_) => println!("No session named {:?} found.", name), - Err(e) => eprintln!("Error occurred: {:?}", e), + Ok(result) => { + if result { + return; + } else { + println!("No session named {:?} found.", name); + if let Some(sugg) = get_sessions().unwrap().suggest(name) { + println!(" help: Did you mean `{}`?", sugg); + } + } + } + Err(e) => { + eprintln!("Error occurred: {:?}", e); + } }; process::exit(1); } |