use anyhow

This commit is contained in:
Cadey Ratio 2020-04-10 07:12:09 -04:00
parent 37a77a6783
commit b4d3cfe960
3 changed files with 23 additions and 12 deletions

7
Cargo.lock generated
View File

@ -9,6 +9,12 @@ dependencies = [
"memchr",
]
[[package]]
name = "anyhow"
version = "1.0.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9a60d744a80c30fcb657dfe2c1b22bcb3e814c1a1e3674f32bf5820b570fbff"
[[package]]
name = "atty"
version = "0.2.14"
@ -54,6 +60,7 @@ checksum = "130aac562c0dd69c56b3b1cc8ffd2e17be31d0b6c25b61c96b76231aa23e39e1"
name = "cabytcini"
version = "0.2.0"
dependencies = [
"anyhow",
"chrono",
"env_logger",
"log",

View File

@ -8,11 +8,12 @@ license = "MIT"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
anyhow = "1.0"
chrono = "0.4"
log = "0.4"
env_logger = "0.7"
serde = { version = "1", features = [ "derive" ] }
log = "0.4"
serde_json = "1"
serde = { version = "1", features = [ "derive" ] }
toml = "0.5"
xdg = "2.2"

View File

@ -3,6 +3,7 @@ mod front;
mod weather;
mod xsetroot;
use anyhow::{Result};
use chrono::prelude::*;
use log::*;
use std::{
@ -51,7 +52,7 @@ fn update_every_so_often(st: MTState) {
}
}
fn main() -> std::io::Result<()> {
fn main() -> Result<()> {
let st: State = State::init();
st.show();
let mtst = Arc::new(Mutex::new(st));
@ -87,8 +88,7 @@ fn main() -> std::io::Result<()> {
thread::spawn(move || handle_client(stream, mtst));
}
Err(err) => {
error!("unix listener error: {:?}", err);
break;
return Err(err.into());
}
}
}
@ -132,13 +132,16 @@ impl State {
}
match &self.weather {
Some(datni) => msg.push_str(format!(
Some(datni) => msg.push_str(
format!(
"{} {} / {} {} | ",
datni.currently.temperature,
datni.currently.summary,
datni.daily.data[0].temperature_high,
datni.daily.data[0].temperature_low
).as_str()),
)
.as_str(),
),
None => {}
};