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::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::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"));
|
||||
// eprintln!("{:#?}", response);
|
||||
match response {
|
||||
Ok(parsed) => {
|
||||
let stamps = parsed.json::<StampsResponse>().unwrap();
|
||||
eprintln!("{:#?}", stamps);
|
||||
// eprintln!("{:#?}", stamps);
|
||||
for stamp in stamps.data {
|
||||
println!("⏳ ({id}) {description}",
|
||||
id=stamp.id,
|
||||
description=stamp.description.unwrap());
|
||||
if last != 0 { break; }
|
||||
}
|
||||
}
|
||||
Err(e) => println!("Error happened: {}", e),
|
||||
|
@ -38,7 +38,8 @@ fn main() {
|
||||
// gst stamps
|
||||
("stamps", Some(_matches)) => {
|
||||
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!!!"),
|
||||
|
Loading…
Reference in New Issue
Block a user