darrylwest / replica-rs

automated backups
1 stars 0 forks source link

specifying the home or working directory #2

Open darrylwest opened 11 months ago

darrylwest commented 11 months ago

might be better to locate the config files in ~/.config/replica/config.toml as the runtime default. that way, an env var like REPLICA_HOME would specify there the app would run, then set it to the repo folder for tests so that the tests don't break. in production, it looks for REPLICA_HOME but uses the default user $HOME when not set.

darrylwest commented 11 months ago

another idea would be to look at the binary path; if it's in the repo space, like replica/target/debug/replica then it's test;o

match env::current_exe() {
    Ok(exe_path) => println!("Path of this executable is: {}", exe_path.display()),
    Err(e) => println!("failed to get current exe path: {e}"),
}

@see https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=f07ba79212c26c5187bf527822a3f063