added "list" option in clap ui
This commit is contained in:
parent
b2bc54c4f8
commit
aa75b5ad9d
2 changed files with 67 additions and 56 deletions
|
@ -18,10 +18,8 @@ use std::process::{Command, Stdio};
|
||||||
use std::io::stdin;
|
use std::io::stdin;
|
||||||
|
|
||||||
use task_hookrs::import::import;
|
use task_hookrs::import::import;
|
||||||
use task_hookrs::task::Task as TTask;
|
|
||||||
|
|
||||||
use libimagrt::runtime::Runtime;
|
use libimagrt::runtime::Runtime;
|
||||||
use libimagtodo::task::Task;
|
|
||||||
use libimagtodo::task::IntoTask;
|
use libimagtodo::task::IntoTask;
|
||||||
use libimagutil::trace::trace_error;
|
use libimagutil::trace::trace_error;
|
||||||
|
|
||||||
|
@ -53,7 +51,7 @@ fn main() {
|
||||||
Some("tw-hook") => {
|
Some("tw-hook") => {
|
||||||
let subcmd = rt.cli().subcommand_matches("tw-hook").unwrap();
|
let subcmd = rt.cli().subcommand_matches("tw-hook").unwrap();
|
||||||
if subcmd.is_present("add") {
|
if subcmd.is_present("add") {
|
||||||
if let Ok(ttasks) = task_hookrs::import::import(stdin()) {
|
if let Ok(ttasks) = import(stdin()) {
|
||||||
for ttask in ttasks {
|
for ttask in ttasks {
|
||||||
println!("{}", match serde_json::ser::to_string(&ttask) {
|
println!("{}", match serde_json::ser::to_string(&ttask) {
|
||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
|
@ -62,7 +60,7 @@ fn main() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let task = match ttask.into_filelockentry(rt.store()) {
|
match ttask.into_filelockentry(rt.store()) {
|
||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
trace_error(&e);
|
trace_error(&e);
|
||||||
|
@ -92,7 +90,7 @@ fn main() {
|
||||||
for e in exec_string {
|
for e in exec_string {
|
||||||
args.push(e);
|
args.push(e);
|
||||||
}
|
}
|
||||||
let mut tw_process = Command::new("task").stdin(Stdio::null()).args(&args).spawn().unwrap_or_else(|e| {
|
let tw_process = Command::new("task").stdin(Stdio::null()).args(&args).spawn().unwrap_or_else(|e| {
|
||||||
panic!("failed to execute taskwarrior: {}", e);
|
panic!("failed to execute taskwarrior: {}", e);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -37,8 +37,8 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.multiple(true)
|
.multiple(true)
|
||||||
.required(true)
|
.required(true)
|
||||||
.help("Args written in the string will be send directly to taskwarrior"))
|
.help("Args written in the string will be send directly to taskwarrior")
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
.subcommand(SubCommand::with_name("add")
|
.subcommand(SubCommand::with_name("add")
|
||||||
|
@ -83,4 +83,17 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
|
||||||
.help("Frequency of the recurrence of a task")
|
.help("Frequency of the recurrence of a task")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
.subcommand(SubCommand::with_name("list")
|
||||||
|
.about("List all tasks")
|
||||||
|
.version("0.1")
|
||||||
|
|
||||||
|
.arg(Arg::with_name("verbose")
|
||||||
|
.long("verbose")
|
||||||
|
.short("v")
|
||||||
|
.takes_value(false)
|
||||||
|
.required(false)
|
||||||
|
.help("Asks taskwarrior for all the details")
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue