Assemble path with home dir
This commit is contained in:
parent
bd7d9ad4eb
commit
92dcbc49fc
1 changed files with 3 additions and 1 deletions
|
|
@ -9,10 +9,12 @@ use elefren::prelude::*;
|
||||||
use elefren::helpers::toml; // requires `features = ["toml"]`
|
use elefren::helpers::toml; // requires `features = ["toml"]`
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn Error>> {
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
|
let home = env::var("HOME").unwrap();
|
||||||
|
let home_config_filename = format!("{}/.mastodon-data.toml", home);
|
||||||
let config_filename = if Path::new("mastodon-data.toml").exists() {
|
let config_filename = if Path::new("mastodon-data.toml").exists() {
|
||||||
"mastodon-data.toml"
|
"mastodon-data.toml"
|
||||||
} else {
|
} else {
|
||||||
"~/.mastodon-data.toml"
|
home_config_filename.as_str()
|
||||||
};
|
};
|
||||||
let mastodon = if let Ok(data) = toml::from_file(config_filename) {
|
let mastodon = if let Ok(data) = toml::from_file(config_filename) {
|
||||||
Mastodon::from(data)
|
Mastodon::from(data)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue