use anyhow
This commit is contained in:
parent
37a77a6783
commit
b4d3cfe960
|
@ -9,6 +9,12 @@ dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "anyhow"
|
||||||
|
version = "1.0.28"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d9a60d744a80c30fcb657dfe2c1b22bcb3e814c1a1e3674f32bf5820b570fbff"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "atty"
|
name = "atty"
|
||||||
version = "0.2.14"
|
version = "0.2.14"
|
||||||
|
@ -54,6 +60,7 @@ checksum = "130aac562c0dd69c56b3b1cc8ffd2e17be31d0b6c25b61c96b76231aa23e39e1"
|
||||||
name = "cabytcini"
|
name = "cabytcini"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
"chrono",
|
"chrono",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"log",
|
"log",
|
||||||
|
|
|
@ -8,11 +8,12 @@ license = "MIT"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
anyhow = "1.0"
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
log = "0.4"
|
|
||||||
env_logger = "0.7"
|
env_logger = "0.7"
|
||||||
serde = { version = "1", features = [ "derive" ] }
|
log = "0.4"
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
|
serde = { version = "1", features = [ "derive" ] }
|
||||||
toml = "0.5"
|
toml = "0.5"
|
||||||
xdg = "2.2"
|
xdg = "2.2"
|
||||||
|
|
||||||
|
|
13
src/main.rs
13
src/main.rs
|
@ -3,6 +3,7 @@ mod front;
|
||||||
mod weather;
|
mod weather;
|
||||||
mod xsetroot;
|
mod xsetroot;
|
||||||
|
|
||||||
|
use anyhow::{Result};
|
||||||
use chrono::prelude::*;
|
use chrono::prelude::*;
|
||||||
use log::*;
|
use log::*;
|
||||||
use std::{
|
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();
|
let st: State = State::init();
|
||||||
st.show();
|
st.show();
|
||||||
let mtst = Arc::new(Mutex::new(st));
|
let mtst = Arc::new(Mutex::new(st));
|
||||||
|
@ -87,8 +88,7 @@ fn main() -> std::io::Result<()> {
|
||||||
thread::spawn(move || handle_client(stream, mtst));
|
thread::spawn(move || handle_client(stream, mtst));
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!("unix listener error: {:?}", err);
|
return Err(err.into());
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,13 +132,16 @@ impl State {
|
||||||
}
|
}
|
||||||
|
|
||||||
match &self.weather {
|
match &self.weather {
|
||||||
Some(datni) => msg.push_str(format!(
|
Some(datni) => msg.push_str(
|
||||||
|
format!(
|
||||||
"{} {} / {} {} | ",
|
"{} {} / {} {} | ",
|
||||||
datni.currently.temperature,
|
datni.currently.temperature,
|
||||||
datni.currently.summary,
|
datni.currently.summary,
|
||||||
datni.daily.data[0].temperature_high,
|
datni.daily.data[0].temperature_high,
|
||||||
datni.daily.data[0].temperature_low
|
datni.daily.data[0].temperature_low
|
||||||
).as_str()),
|
)
|
||||||
|
.as_str(),
|
||||||
|
),
|
||||||
None => {}
|
None => {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue