bhcli

A TUI for chatting on LE PHP Chats (onion)
git clone https://git.dasho.dev/n0tr1v/bhcli.git
Log | Files | Refs | README

commit 47e3bc0a13cb9f21a66f723356781e5b7ee1a321
parent e52344987f7e58a05ac1226c85d5983b0bb2ec82
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Fri,  7 Apr 2023 00:54:34 -0700

fix config crash

Diffstat:
Msrc/main.rs | 21++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -1840,15 +1840,18 @@ fn main() -> anyhow::Result<()> { let mut opts: Opts = Opts::parse(); // Configs file - println!("Config path: {:?}", confy::get_configuration_file_path("bhcli", None)?); - let cfg: MyConfig = confy::load("bhcli", None)?; - if opts.dkf_api_key.is_none() { - opts.dkf_api_key = cfg.dkf_api_key; - } - if let Some(default_profile) = cfg.profiles.get(&opts.profile) { - if opts.username.is_none() { - opts.username = Some(default_profile.username.clone()); - opts.password = Some(default_profile.password.clone()); + if let Ok(config_path) = confy::get_configuration_file_path("bhcli", None) { + println!("Config path: {:?}", config_path); + } + if let Ok(cfg) = confy::load::<MyConfig>("bhcli", None) { + if opts.dkf_api_key.is_none() { + opts.dkf_api_key = cfg.dkf_api_key; + } + if let Some(default_profile) = cfg.profiles.get(&opts.profile) { + if opts.username.is_none() { + opts.username = Some(default_profile.username.clone()); + opts.password = Some(default_profile.password.clone()); + } } }