Add: last stamp (-l or --last) feature in stamps subcommand
This commit is contained in:
parent
dc96f2d423
commit
91b918a70e
@ -21,7 +21,13 @@ 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("last")
|
||||||
|
.short("l")
|
||||||
|
.long("last")
|
||||||
|
.help("List last stamp only")
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.subcommand(
|
.subcommand(
|
||||||
SubCommand::with_name("tasks")
|
SubCommand::with_name("tasks")
|
||||||
|
@ -115,17 +115,18 @@ pub fn get_tasks(config_file: &PathBuf, project: u32) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_stamps(config_file: &PathBuf) {
|
pub fn get_stamps(config_file: &PathBuf, last: u64) {
|
||||||
let response = api_call(&config_file, String::from("stamps"));
|
let response = api_call(&config_file, String::from("stamps"));
|
||||||
// eprintln!("{:#?}", response);
|
// eprintln!("{:#?}", response);
|
||||||
match response {
|
match response {
|
||||||
Ok(parsed) => {
|
Ok(parsed) => {
|
||||||
let stamps = parsed.json::<StampsResponse>().unwrap();
|
let stamps = parsed.json::<StampsResponse>().unwrap();
|
||||||
eprintln!("{:#?}", stamps);
|
// eprintln!("{:#?}", stamps);
|
||||||
for stamp in stamps.data {
|
for stamp in stamps.data {
|
||||||
println!("⏳ ({id}) {description}",
|
println!("⏳ ({id}) {description}",
|
||||||
id=stamp.id,
|
id=stamp.id,
|
||||||
description=stamp.description.unwrap());
|
description=stamp.description.unwrap());
|
||||||
|
if last != 0 { break; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => println!("Error happened: {}", e),
|
Err(e) => println!("Error happened: {}", e),
|
||||||
|
@ -38,7 +38,8 @@ fn main() {
|
|||||||
// gst stamps
|
// gst stamps
|
||||||
("stamps", Some(_matches)) => {
|
("stamps", Some(_matches)) => {
|
||||||
console::info("List of stamps");
|
console::info("List of stamps");
|
||||||
cmd::get_stamps(&config_file);
|
let last = _matches.occurrences_of("last");
|
||||||
|
cmd::get_stamps(&config_file, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => console::error("Whut!!!"),
|
_ => console::error("Whut!!!"),
|
||||||
|
Loading…
Reference in New Issue
Block a user