Add: Duration field in Stamp
This commit is contained in:
parent
56e02021c7
commit
5ce6fb8f60
@ -112,7 +112,7 @@ fn main() {
|
|||||||
match task {
|
match task {
|
||||||
0 => panic!("Need some task number to add the stamp"),
|
0 => panic!("Need some task number to add the stamp"),
|
||||||
_ => {
|
_ => {
|
||||||
let stamp = Stamp::new(&config_file, dstart, dend, description, task);
|
let stamp = Stamp::new(&config_file, dstart, dend, description, task, "");
|
||||||
let added = stamp.api_post(&config_file, "stamp/add");
|
let added = stamp.api_post(&config_file, "stamp/add");
|
||||||
match added.status() {
|
match added.status() {
|
||||||
reqwest::StatusCode::OK => println!("OK"),
|
reqwest::StatusCode::OK => println!("OK"),
|
||||||
@ -124,7 +124,7 @@ fn main() {
|
|||||||
// gst stamp --stop
|
// gst stamp --stop
|
||||||
else if stop == 1 {
|
else if stop == 1 {
|
||||||
console::info("Stop last stamp");
|
console::info("Stop last stamp");
|
||||||
let stamp = Stamp::new(&config_file, "", "", "", 0);
|
let stamp = Stamp::new(&config_file, "", "", "", 0, "");
|
||||||
let stopped = stamp.api_post(&config_file, "stamp/stop");
|
let stopped = stamp.api_post(&config_file, "stamp/stop");
|
||||||
match stopped.status() {
|
match stopped.status() {
|
||||||
reqwest::StatusCode::OK => println!("OK"),
|
reqwest::StatusCode::OK => println!("OK"),
|
||||||
@ -134,7 +134,7 @@ fn main() {
|
|||||||
// gst stamp --update --description "desc" --dstart "20120101" --dend "20120101"
|
// gst stamp --update --description "desc" --dstart "20120101" --dend "20120101"
|
||||||
else if update == 1 {
|
else if update == 1 {
|
||||||
console::info("Update last stamp");
|
console::info("Update last stamp");
|
||||||
let stamp = Stamp::new(&config_file, dstart, dend, description, task);
|
let stamp = Stamp::new(&config_file, dstart, dend, description, task, "");
|
||||||
let updated = stamp.api_post(&config_file, "stamp/update");
|
let updated = stamp.api_post(&config_file, "stamp/update");
|
||||||
match updated.status() {
|
match updated.status() {
|
||||||
reqwest::StatusCode::OK => println!("OK"),
|
reqwest::StatusCode::OK => println!("OK"),
|
||||||
|
@ -12,6 +12,7 @@ pub struct Stamp {
|
|||||||
pub end: Option<String>,
|
pub end: Option<String>,
|
||||||
pub description: Option<String>,
|
pub description: Option<String>,
|
||||||
pub task_id: Option<u32>,
|
pub task_id: Option<u32>,
|
||||||
|
pub duration: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Stamp {
|
impl Stamp {
|
||||||
@ -19,7 +20,8 @@ impl Stamp {
|
|||||||
dstart: &str,
|
dstart: &str,
|
||||||
dend: &str,
|
dend: &str,
|
||||||
description: &str,
|
description: &str,
|
||||||
task: u32
|
task: u32,
|
||||||
|
duration: &str,
|
||||||
) -> Stamp {
|
) -> Stamp {
|
||||||
// Config
|
// Config
|
||||||
let mut default_config = config::Config::default();
|
let mut default_config = config::Config::default();
|
||||||
@ -32,6 +34,7 @@ impl Stamp {
|
|||||||
end: Some(dend.to_string()),
|
end: Some(dend.to_string()),
|
||||||
description: Some(description.to_string()),
|
description: Some(description.to_string()),
|
||||||
task_id: Some(task),
|
task_id: Some(task),
|
||||||
|
duration: Some(duration.to_string()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,19 +83,30 @@ 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 {
|
||||||
|
let mut open: String = String::from("");
|
||||||
|
match stamp.end {
|
||||||
|
None => open = "⏸️ ".to_string(),
|
||||||
|
_ => {
|
||||||
|
let op: String = format_args!("{duration}",
|
||||||
|
duration=stamp.duration.unwrap().to_string()
|
||||||
|
).to_string();
|
||||||
|
open = op;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let output: String = format_args!("⏳ ({id}) {open} - {description}",
|
||||||
|
open=open,
|
||||||
|
id=stamp.id,
|
||||||
|
description=stamp.description.unwrap()
|
||||||
|
).to_string();
|
||||||
match project {
|
match project {
|
||||||
0 => {
|
0 => {
|
||||||
println!("⏳ ({id}) {description}",
|
println!("{}", output);
|
||||||
id=stamp.id,
|
|
||||||
description=stamp.description.unwrap());
|
|
||||||
if last != 0 { break; }
|
if last != 0 { break; }
|
||||||
},
|
},
|
||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
if project == stamp.project_id {
|
if project == stamp.project_id {
|
||||||
println!("⏳ ({id}) {description}",
|
println!("{}", output);
|
||||||
id=stamp.id,
|
|
||||||
description=stamp.description.unwrap());
|
|
||||||
if last != 0 { break; }
|
if last != 0 { break; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user