implemented todo
This commit is contained in:
7
Cargo.lock
generated
7
Cargo.lock
generated
@@ -83,9 +83,16 @@ name = "i3status-custom-pim"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"json",
|
||||
"structopt",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "json"
|
||||
version = "0.12.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "078e285eafdfb6c4b434e0d31e8cfcb5115b651496faca5749b88fafd4f23bfd"
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
|
||||
@@ -10,3 +10,4 @@ edition = "2018"
|
||||
[dependencies]
|
||||
structopt = "0.3"
|
||||
chrono = "0.4"
|
||||
json = "0.12.4"
|
||||
|
||||
44
src/main.rs
44
src/main.rs
@@ -143,6 +143,48 @@ fn main() {
|
||||
args.icon, state, count
|
||||
);
|
||||
} else if args.todo {
|
||||
println!("todo output");
|
||||
let cmd = Command::new("todo")
|
||||
.arg("--porcelain")
|
||||
.output();
|
||||
|
||||
let stdout = match cmd {
|
||||
Ok(o) => o.stdout,
|
||||
Err(e) => {
|
||||
eprintln!("Error running todo: {}", e);
|
||||
process::exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
let output = match String::from_utf8(stdout) {
|
||||
Ok(o) => o,
|
||||
Err(e) => {
|
||||
eprintln!("Converting output failed: {}", e);
|
||||
process::exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
let mut parsed = match json::parse(&output){
|
||||
Ok(p) => p,
|
||||
Err(e) => {
|
||||
eprintln!("parsing JSON failed: {}", e);
|
||||
process::exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
let count = parsed.len();
|
||||
println!("{:#?}", count);
|
||||
|
||||
let mut tasks: Vec<String> = Vec::new();
|
||||
for due in parsed.members() {
|
||||
tasks.push(due.as_str().unwrap().to_string());
|
||||
}
|
||||
/*
|
||||
for i in parsed {
|
||||
i.foo();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user