1
0
mirror of https://github.com/pcvolkmer/checkbar.git synced 2025-04-19 19:16:50 +00:00

Code cleanup

This commit is contained in:
Paul-Christian Volkmer 2022-12-23 00:10:52 +01:00
parent bfb9e9b6cd
commit 5e9018112c

View File

@ -1,7 +1,7 @@
use serde::Deserialize;
use serde_json::json;
use std::fmt::{Display, Formatter, Result};
use std::env;
use std::fmt::{Display, Formatter, Result};
use std::fs;
use std::process;
use std::time::Duration;
@ -123,16 +123,22 @@ async fn print_states(check_configs: &[CheckConfig]) {
for check_config in check_configs {
entries.push(format!("{}", check_host(check_config).await));
}
entries.push(json!({
entries.push(
json!({
"full_text": chrono::Local::now().format("%H:%M").to_string()
}).to_string());
})
.to_string(),
);
println!("{}],", entries.join(","));
}
fn get_config_file() -> String {
match env::args().nth(1) {
Some(config_file) => config_file,
None => format!("{}/.checkbar.toml", dirs::home_dir().unwrap().to_str().unwrap_or(""))
None => format!(
"{}/.checkbar.toml",
dirs::home_dir().unwrap().to_str().unwrap_or("")
),
}
}
@ -175,10 +181,13 @@ async fn run_click_cmd(cmd: String) {
#[tokio::main(flavor = "multi_thread", worker_threads = 2)]
async fn main() {
println!("{}", json!({
println!(
"{}",
json!({
"version": 1,
"click_events": true
}));
})
);
println!("[");
let inputs = task::spawn(async {