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);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use clap::{Arg, App, ArgGroup, SubCommand};
|
use clap::{Arg, App, ArgGroup, SubCommand};
|
||||||
|
|
||||||
pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
|
pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
|
||||||
app
|
app
|
||||||
.subcommand(SubCommand::with_name("tw-hook")
|
.subcommand(SubCommand::with_name("tw-hook")
|
||||||
.about("For use in a taskwarrior hook")
|
.about("For use in a taskwarrior hook")
|
||||||
.version("0.1")
|
.version("0.1")
|
||||||
|
@ -22,65 +22,78 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
|
||||||
|
|
||||||
.group(ArgGroup::with_name("taskwarrior hooks")
|
.group(ArgGroup::with_name("taskwarrior hooks")
|
||||||
.args(&[ "add",
|
.args(&[ "add",
|
||||||
"delete",
|
"delete",
|
||||||
])
|
])
|
||||||
.required(true))
|
.required(true))
|
||||||
)
|
)
|
||||||
|
|
||||||
.subcommand(SubCommand::with_name("exec")
|
.subcommand(SubCommand::with_name("exec")
|
||||||
.about("Send a command to taskwarrior")
|
.about("Send a command to taskwarrior")
|
||||||
.version("0.1")
|
.version("0.1")
|
||||||
|
|
||||||
.arg(Arg::with_name("command")
|
.arg(Arg::with_name("command")
|
||||||
.long("command")
|
.long("command")
|
||||||
.short("c")
|
.short("c")
|
||||||
.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")
|
||||||
|
.about("create a task")
|
||||||
|
.version("0.1")
|
||||||
|
|
||||||
.subcommand(SubCommand::with_name("add")
|
.arg(Arg::with_name("description")
|
||||||
.about("create a task")
|
.long("description")
|
||||||
.version("0.1")
|
.short("d")
|
||||||
|
.takes_value(true)
|
||||||
|
.required(true)
|
||||||
|
.help("Name/Description of the new task")
|
||||||
|
)
|
||||||
|
|
||||||
.arg(Arg::with_name("description")
|
.arg(Arg::with_name("priority")
|
||||||
.long("description")
|
.long("priority")
|
||||||
.short("d")
|
.short("p")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.required(true)
|
.required(false)
|
||||||
.help("Name/Description of the new task")
|
.help("One of l, m, h for low, medium and high priority")
|
||||||
)
|
)
|
||||||
|
|
||||||
.arg(Arg::with_name("priority")
|
.arg(Arg::with_name("project")
|
||||||
.long("priority")
|
.long("project")
|
||||||
.short("p")
|
.takes_value(true)
|
||||||
.takes_value(true)
|
.required(false)
|
||||||
.required(false)
|
.help("Name of the project the task is related to")
|
||||||
.help("One of l, m, h for low, medium and high priority")
|
)
|
||||||
)
|
|
||||||
|
|
||||||
.arg(Arg::with_name("project")
|
.arg(Arg::with_name("due")
|
||||||
.long("project")
|
.long("due")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.required(false)
|
.required(false)
|
||||||
.help("Name of the project the task is related to")
|
.help("Due date of the new task")
|
||||||
)
|
)
|
||||||
|
|
||||||
.arg(Arg::with_name("due")
|
.arg(Arg::with_name("frequency")
|
||||||
.long("due")
|
.long("frequency")
|
||||||
.takes_value(true)
|
.short("f")
|
||||||
.required(false)
|
.takes_value(true)
|
||||||
.help("Due date of the new task")
|
.required(false)
|
||||||
)
|
.help("Frequency of the recurrence of a task")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
.arg(Arg::with_name("frequency")
|
.subcommand(SubCommand::with_name("list")
|
||||||
.long("frequency")
|
.about("List all tasks")
|
||||||
.short("f")
|
.version("0.1")
|
||||||
.takes_value(true)
|
|
||||||
.required(false)
|
.arg(Arg::with_name("verbose")
|
||||||
.help("Frequency of the recurrence of a task")
|
.long("verbose")
|
||||||
)
|
.short("v")
|
||||||
)
|
.takes_value(false)
|
||||||
|
.required(false)
|
||||||
|
.help("Asks taskwarrior for all the details")
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue