use util_str::read_str_to_lines
This commit is contained in:
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -944,9 +944,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rust_util"
|
name = "rust_util"
|
||||||
version = "0.2.4"
|
version = "0.2.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "78e3a554df0a4e66701f3971ab0f55737d6da2bb5511a9b61da9d22dd6581d09"
|
checksum = "854b942370a20552f9ab927cdc4e88d1d29c59c17f07729930031c26afad16ec"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"libc",
|
"libc",
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ tokio = { version = "0.2.6", features = ["full"] }
|
|||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
argparse = "0.2.2"
|
argparse = "0.2.2"
|
||||||
rust_util = "0.2.4"
|
rust_util = "0.2.5"
|
||||||
dingtalk = "1.3.2"
|
dingtalk = "1.3.2"
|
||||||
chrono = "0.4.11"
|
chrono = "0.4.11"
|
||||||
# log = "0.4.8"
|
# log = "0.4.8"
|
||||||
|
|||||||
33
src/main.rs
33
src/main.rs
@@ -9,6 +9,7 @@ use std::{
|
|||||||
use chrono::prelude::*;
|
use chrono::prelude::*;
|
||||||
use serde::{ Deserialize, Serialize, };
|
use serde::{ Deserialize, Serialize, };
|
||||||
use rust_util::{
|
use rust_util::{
|
||||||
|
util_str::read_str_to_lines,
|
||||||
util_file::locate_file,
|
util_file::locate_file,
|
||||||
util_msg::{ print_info, print_error, print_debug, }
|
util_msg::{ print_info, print_error, print_debug, }
|
||||||
};
|
};
|
||||||
@@ -139,35 +140,3 @@ fn ps_aux() -> Option<String> {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Split string to lines, splited by '\r', '\n' or "\r\n"
|
|
||||||
fn read_str_to_lines(s: &str) -> Vec<String> {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user