From bd7d9ad4ebcc1db0acc5e159bb85db7a3269cf45 Mon Sep 17 00:00:00 2001 From: Stefan Schlott Date: Wed, 21 Sep 2022 08:26:05 +0200 Subject: [PATCH] Alternative location for toot config --- toot/src/main.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/toot/src/main.rs b/toot/src/main.rs index d7be1d6e..9f84982f 100644 --- a/toot/src/main.rs +++ b/toot/src/main.rs @@ -2,13 +2,19 @@ extern crate elefren; use std::env; use std::io; +use std::path::Path; use std::error::Error; use elefren::prelude::*; use elefren::helpers::toml; // requires `features = ["toml"]` fn main() -> Result<(), Box> { - let mastodon = if let Ok(data) = toml::from_file("mastodon-data.toml") { + let config_filename = if Path::new("mastodon-data.toml").exists() { + "mastodon-data.toml" + } else { + "~/.mastodon-data.toml" + }; + let mastodon = if let Ok(data) = toml::from_file(config_filename) { Mastodon::from(data) } else { register()?