implemented todo

This commit is contained in:
2020-11-22 17:05:45 +01:00
parent 14d39c1f05
commit 57142c6645
3 changed files with 51 additions and 1 deletions

7
Cargo.lock generated
View File

@@ -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"

View File

@@ -10,3 +10,4 @@ edition = "2018"
[dependencies]
structopt = "0.3"
chrono = "0.4"
json = "0.12.4"

View File

@@ -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();
}
*/
}
}