Move post_history module out of subdir, port logging from tui to println/journald
This commit is contained in:
parent
89b2d19c80
commit
f2730a8eaf
1 changed files with 12 additions and 3 deletions
|
@ -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 => {
|
Loading…
Reference in a new issue