Alternative location for toot config
This commit is contained in:
parent
7650f9facc
commit
bd7d9ad4eb
1 changed files with 7 additions and 1 deletions
|
|
@ -2,13 +2,19 @@ extern crate elefren;
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
use std::path::Path;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
|
||||||
use elefren::prelude::*;
|
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 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)
|
Mastodon::from(data)
|
||||||
} else {
|
} else {
|
||||||
register()?
|
register()?
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue