diff --git a/Cargo.lock b/Cargo.lock index a95fd99..8ef1c66 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -944,9 +944,9 @@ dependencies = [ [[package]] name = "rust_util" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78e3a554df0a4e66701f3971ab0f55737d6da2bb5511a9b61da9d22dd6581d09" +checksum = "854b942370a20552f9ab927cdc4e88d1d29c59c17f07729930031c26afad16ec" dependencies = [ "lazy_static", "libc", diff --git a/Cargo.toml b/Cargo.toml index 1f6402f..dd2026d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ tokio = { version = "0.2.6", features = ["full"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" argparse = "0.2.2" -rust_util = "0.2.4" +rust_util = "0.2.5" dingtalk = "1.3.2" chrono = "0.4.11" # log = "0.4.8" diff --git a/src/main.rs b/src/main.rs index cbf6356..1b56f2d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,6 +9,7 @@ use std::{ use chrono::prelude::*; use serde::{ Deserialize, Serialize, }; use rust_util::{ + util_str::read_str_to_lines, util_file::locate_file, util_msg::{ print_info, print_error, print_debug, } }; @@ -139,35 +140,3 @@ fn ps_aux() -> Option { }, } } - -/// Split string to lines, splited by '\r', '\n' or "\r\n" -fn read_str_to_lines(s: &str) -> Vec { - let mut r = vec![]; - let mut line = String::new(); - let mut cs = s.chars(); - while let Some(c) = cs.next() { - if c == '\n' || c == '\r' { - r.push(line.clone()); - line.clear(); - if c == '\r' { - if let Some(nc) = cs.next() { - if nc == '\n' { - // IGNORE - } else if nc == '\r' { - r.push("".to_owned()); - } else { - line.push(nc); - } - } else { - break; - } - } - } else { - line.push(c); - } - } - if !line.is_empty() { - r.push(line); - } - r -} \ No newline at end of file