Use CWD if no directory is provided.
This commit is contained in:
parent
41a9a2a3bf
commit
a29ae43e84
14
src/main.rs
14
src/main.rs
@ -49,12 +49,14 @@ struct Cli {
|
|||||||
fn main() -> Result<(), Box<dyn Error>> {
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
let args = Cli::from_args();
|
let args = Cli::from_args();
|
||||||
|
|
||||||
// If the CLI was provided a directory to open use it.
|
let root_path = match args.path {
|
||||||
// Otherwise, attempt to find the home directory. If that fails use CWD.
|
// If the CLI was provided a directory convert it to absolute.
|
||||||
let root_path = args
|
Some(path) => std::path::absolute(path)?,
|
||||||
.path
|
// If no path was provided, use current directory.
|
||||||
.or_else(dirs::home_dir)
|
None => std::env::current_dir().unwrap_or_else(|_|
|
||||||
.unwrap_or_else(|| std::env::current_dir().expect("Failed to access filesystem."));
|
// 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.
|
// Open the TUI editor if requested, otherwise use the QML GUI by default.
|
||||||
match args.tui {
|
match args.tui {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user