Add: --project argument to "stamps" for listing stamps per project
This commit is contained in:
parent
0e8e12b453
commit
9f7d2648c4
@ -22,6 +22,14 @@ pub fn build_cli() -> App<'static, 'static> {
|
|||||||
.subcommand(
|
.subcommand(
|
||||||
SubCommand::with_name("stamps")
|
SubCommand::with_name("stamps")
|
||||||
.about("List last stamps")
|
.about("List last stamps")
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("project")
|
||||||
|
.short("p")
|
||||||
|
.long("project")
|
||||||
|
.value_name("PROJECT")
|
||||||
|
.help("Provides a project to list stamps from")
|
||||||
|
.takes_value(true),
|
||||||
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("last")
|
Arg::with_name("last")
|
||||||
.short("l")
|
.short("l")
|
||||||
|
@ -55,18 +55,21 @@ fn main() {
|
|||||||
tasks.get(&config_file, project, last);
|
tasks.get(&config_file, project, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
// gst stamps [--last]
|
// gst stamps [--project] [--last]
|
||||||
("stamps", Some(_matches)) => {
|
("stamps", Some(_matches)) => {
|
||||||
console::info("List of stamps");
|
console::info("List of stamps");
|
||||||
let last = _matches.occurrences_of("last");
|
let last = _matches.occurrences_of("last");
|
||||||
|
let project = _matches.value_of("project")
|
||||||
|
.unwrap_or("0").trim().parse()
|
||||||
|
.expect("Type a number!");
|
||||||
let stamps = Stamps {
|
let stamps = Stamps {
|
||||||
data: Vec::new(),
|
data: Vec::new(),
|
||||||
error: "".to_string(),
|
error: "".to_string(),
|
||||||
};
|
};
|
||||||
stamps.get(&config_file, last);
|
stamps.get(&config_file, project, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
// gst addtask [--project] "title"
|
// gst addtask --project NUM --title "title" --description "desc"
|
||||||
("addtask", Some(_matches)) => {
|
("addtask", Some(_matches)) => {
|
||||||
console::info("Add a new task");
|
console::info("Add a new task");
|
||||||
let project: u32 = _matches.value_of("project")
|
let project: u32 = _matches.value_of("project")
|
||||||
|
@ -20,7 +20,7 @@ pub struct Stamps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Stamps {
|
impl Stamps {
|
||||||
pub fn get(&self, config_file: &PathBuf, last: u64) {
|
pub fn get(&self, config_file: &PathBuf, project: u32, last: u64) {
|
||||||
// Config
|
// Config
|
||||||
let mut default_config = config::Config::default();
|
let mut default_config = config::Config::default();
|
||||||
let config = default_config.parse(&config_file);
|
let config = default_config.parse(&config_file);
|
||||||
@ -39,10 +39,23 @@ impl Stamps {
|
|||||||
let stamps = parsed.json::<Stamps>().unwrap();
|
let stamps = parsed.json::<Stamps>().unwrap();
|
||||||
// eprintln!("{:#?}", stamps);
|
// eprintln!("{:#?}", stamps);
|
||||||
for stamp in stamps.data {
|
for stamp in stamps.data {
|
||||||
println!("⏳ ({id}) {description}",
|
match project {
|
||||||
id=stamp.id,
|
0 => {
|
||||||
description=stamp.description.unwrap());
|
println!("⏳ ({id}) {description}",
|
||||||
if last != 0 { break; }
|
id=stamp.id,
|
||||||
|
description=stamp.description.unwrap());
|
||||||
|
if last != 0 { break; }
|
||||||
|
},
|
||||||
|
|
||||||
|
_ => {
|
||||||
|
if project == stamp.project_id {
|
||||||
|
println!("⏳ ({id}) {description}",
|
||||||
|
id=stamp.id,
|
||||||
|
description=stamp.description.unwrap());
|
||||||
|
if last != 0 { break; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => println!("Error happened: {}", e),
|
Err(e) => println!("Error happened: {}", e),
|
||||||
|
Loading…
Reference in New Issue
Block a user