From a29ae43e84bff8038ed38521ea569bf6fb783a08 Mon Sep 17 00:00:00 2001 From: Shaun Reed Date: Sun, 13 Apr 2025 11:01:37 -0400 Subject: [PATCH] Use CWD if no directory is provided. --- src/main.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 03f1108..1b35fab 100644 --- a/src/main.rs +++ b/src/main.rs @@ -49,12 +49,14 @@ struct Cli { fn main() -> Result<(), Box> { let args = Cli::from_args(); - // If the CLI was provided a directory to open use it. - // Otherwise, attempt to find the home directory. If that fails use CWD. - let root_path = args - .path - .or_else(dirs::home_dir) - .unwrap_or_else(|| std::env::current_dir().expect("Failed to access filesystem.")); + let root_path = match args.path { + // If the CLI was provided a directory convert it to absolute. + Some(path) => std::path::absolute(path)?, + // If no path was provided, use current directory. + None => std::env::current_dir().unwrap_or_else(|_| + // If we can't find the CWD attempt to open the home directory. + dirs::home_dir().expect("Failed to access filesystem.")), + }; // Open the TUI editor if requested, otherwise use the QML GUI by default. match args.tui {