Removes the TUI in favor of event based logging #15

Merged
Neshura merged 17 commits from remove_tui into main 2023-12-30 00:28:47 +00:00
Showing only changes of commit f2730a8eaf - Show all commits

View file

@ -4,6 +4,7 @@ use std::fs::OpenOptions;
use std::io::Write; use std::io::Write;
use std::path::Path; use std::path::Path;
use serde_derive::{Deserialize, Serialize}; use serde_derive::{Deserialize, Serialize};
use crate::write_error;
#[derive(Serialize, Deserialize, Clone, Debug)] #[derive(Serialize, Deserialize, Clone, Debug)]
pub(crate) struct SeriesHistory { pub(crate) struct SeriesHistory {
@ -11,7 +12,7 @@ pub(crate) struct SeriesHistory {
} }
impl SeriesHistory { impl SeriesHistory {
pub(crate) fn load_history() -> Result<Self, String> { pub(crate) fn load_history() -> Result<Self, ()> {
let path = confy::get_configuration_file_path(env!("CARGO_PKG_NAME"), "config").expect("Something went wrong with confy"); let path = confy::get_configuration_file_path(env!("CARGO_PKG_NAME"), "config").expect("Something went wrong with confy");
let config_dir = path.parent().expect("Something went wrong with confy"); let config_dir = path.parent().expect("Something went wrong with confy");
@ -21,7 +22,11 @@ impl SeriesHistory {
true => { true => {
let file_contents: String = match fs::read_to_string("history.toml") { let file_contents: String = match fs::read_to_string("history.toml") {
Ok(data) => data, Ok(data) => data,
Err(e) => return Err(format!("{}", e)), Err(e) => {
let err_msg = format!("{e}");
write_error(err_msg);
return Err(())
},
}; };
let history: Result<SeriesHistory, toml::de::Error> = match file_contents.len() { let history: Result<SeriesHistory, toml::de::Error> = match file_contents.len() {
@ -33,7 +38,11 @@ impl SeriesHistory {
match history { match history {
Ok(data) => Ok(data), Ok(data) => Ok(data),
Err(e) => Err(format!("{}", e)) Err(e) => {
let err_msg = format!("{e}");
write_error(err_msg);
Err(())
}
} }
}, },
false => { false => {