Add: New "addtask" command
This commit is contained in:
parent
aba7a2bc03
commit
effdbb778a
28
src/cli.rs
28
src/cli.rs
@ -41,4 +41,32 @@ pub fn build_cli() -> App<'static, 'static> {
|
|||||||
.takes_value(true),
|
.takes_value(true),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
.subcommand(
|
||||||
|
SubCommand::with_name("addtask")
|
||||||
|
.about("Add a new task to a project")
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("project")
|
||||||
|
.short("p")
|
||||||
|
.long("project")
|
||||||
|
.value_name("PROJECT")
|
||||||
|
.help("Provides a project to list tasks from")
|
||||||
|
.takes_value(true),
|
||||||
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("title")
|
||||||
|
.short("t")
|
||||||
|
.long("title")
|
||||||
|
.value_name("TITLE")
|
||||||
|
.help("Task title")
|
||||||
|
.takes_value(true),
|
||||||
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("description")
|
||||||
|
.short("d")
|
||||||
|
.long("description")
|
||||||
|
.value_name("DESCRIPTION")
|
||||||
|
.help("Task description")
|
||||||
|
.takes_value(true),
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
27
src/main.rs
27
src/main.rs
@ -2,7 +2,6 @@ use std::{process};
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
mod cli;
|
mod cli;
|
||||||
mod cmd;
|
|
||||||
pub mod console;
|
pub mod console;
|
||||||
|
|
||||||
#[path = "./models/tasks.rs"]
|
#[path = "./models/tasks.rs"]
|
||||||
@ -66,6 +65,32 @@ fn main() {
|
|||||||
stamps.get(&config_file, last);
|
stamps.get(&config_file, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// gst addtask [--project] "title"
|
||||||
|
("addtask", Some(_matches)) => {
|
||||||
|
console::info("Add a new task");
|
||||||
|
let project: u32 = _matches.value_of("project")
|
||||||
|
.unwrap_or("0").trim().parse()
|
||||||
|
.expect("Type a number!");
|
||||||
|
let title: &str = _matches.value_of("title")
|
||||||
|
.unwrap_or("").trim();
|
||||||
|
let description: &str = _matches.value_of("description")
|
||||||
|
.unwrap_or("").trim();
|
||||||
|
let task = Task {
|
||||||
|
id: 0,
|
||||||
|
name: title.to_string(),
|
||||||
|
description: Some(description.to_string()),
|
||||||
|
project_id: project,
|
||||||
|
estimated: Some("1:00:00".to_string()),
|
||||||
|
};
|
||||||
|
// println!("{:?}", task);
|
||||||
|
let added = task.add(&config_file);
|
||||||
|
// println!("{:#?}", added);
|
||||||
|
match added.status() {
|
||||||
|
reqwest::StatusCode::OK => println!("OK"),
|
||||||
|
other => println!("KO: {:?}, something happened", other),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_ => console::error("Whut!!!"),
|
_ => console::error("Whut!!!"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user