(3a68c7) Add created at timestamp
This commit is contained in:
+44
-9
@@ -1,4 +1,5 @@
|
||||
use anyhow::{Result, anyhow};
|
||||
use chrono::Local;
|
||||
use clap::Parser;
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
@@ -75,6 +76,21 @@ fn parse_ticket_field(content: &str, field: &str) -> String {
|
||||
.to_string()
|
||||
}
|
||||
|
||||
fn format_created_at(created_at: &str) -> String {
|
||||
if created_at == "_Not set_" || created_at.is_empty() {
|
||||
return "".to_string();
|
||||
}
|
||||
if created_at.len() < 16 {
|
||||
return created_at.to_string();
|
||||
}
|
||||
// Parse "YYYY-MM-DD HH:MM:SS" -> "YY-MM-DD:HH"
|
||||
let year = &created_at[2..4];
|
||||
let month = &created_at[5..7];
|
||||
let day = &created_at[8..10];
|
||||
let hour = &created_at[11..13];
|
||||
format!("{}-{}-{}:{}", year, month, day, hour)
|
||||
}
|
||||
|
||||
fn status_dirs() -> Vec<&'static str> {
|
||||
vec!["backlog", "committed", "reviewing", "done"]
|
||||
}
|
||||
@@ -108,16 +124,24 @@ fn cmd_ls(status_filter: &Option<String>, worklane_dir: &Path) -> Result<()> {
|
||||
.to_string();
|
||||
let owner = parse_ticket_field(&content, "Owner");
|
||||
let due = parse_ticket_field(&content, "Due");
|
||||
let filename = e.path().file_stem()?.to_string_lossy().to_string();
|
||||
let uuid_short = if filename.len() > 7 { &filename[..7] } else { &filename };
|
||||
let created_at = parse_ticket_field(&content, "Created At");
|
||||
let short_date = format_created_at(&created_at);
|
||||
|
||||
Some((title, owner, due))
|
||||
Some((title, owner, due, uuid_short.to_string(), short_date))
|
||||
})
|
||||
.collect();
|
||||
|
||||
items.sort_by(|a, b| a.0.to_lowercase().cmp(&b.0.to_lowercase()));
|
||||
|
||||
println!("Tickets in '{}' status:\n", status);
|
||||
for (title, owner, due) in items {
|
||||
println!(" {} | Owner: {} | Due: {}", title, owner, due);
|
||||
for (title, owner, due, uuid, ts) in items {
|
||||
if ts.is_empty() {
|
||||
println!(" ({}) {} | Owner: {} | Due: {}", uuid, title, owner, due);
|
||||
} else {
|
||||
println!(" ({}:{}) {} | Owner: {} | Due: {}", uuid, ts, title, owner, due);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// List all statuses with their ticket counts
|
||||
@@ -156,13 +180,22 @@ fn cmd_ls(status_filter: &Option<String>, worklane_dir: &Path) -> Result<()> {
|
||||
.to_string();
|
||||
let owner = parse_ticket_field(&content, "Owner");
|
||||
let due = parse_ticket_field(&content, "Due");
|
||||
Some((title, owner, due))
|
||||
let filename = e.path().file_stem()?.to_string_lossy().to_string();
|
||||
let uuid_short = if filename.len() > 7 { &filename[..7] } else { &filename };
|
||||
let created_at = parse_ticket_field(&content, "Created At");
|
||||
let short_date = format_created_at(&created_at);
|
||||
|
||||
Some((title, owner, due, uuid_short.to_string(), short_date))
|
||||
})
|
||||
.collect();
|
||||
items.sort_by(|a, b| a.0.to_lowercase().cmp(&b.0.to_lowercase()));
|
||||
println!("\n[{}]", status.to_uppercase());
|
||||
for (title, owner, due) in items {
|
||||
println!(" {} | Owner: {} | Due: {}", title, owner, due);
|
||||
for (title, owner, due, uuid, ts) in items {
|
||||
if ts.is_empty() {
|
||||
println!(" ({}) {} | Owner: {} | Due: {}", uuid, title, owner, due);
|
||||
} else {
|
||||
println!(" ({}:{}) {} | Owner: {} | Due: {}", uuid, ts, title, owner, due);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -219,9 +252,10 @@ fn cmd_add(
|
||||
- **ID**: {}\n\
|
||||
- **Tags**: {}\n\
|
||||
- **Due**: {}\n\
|
||||
- **Owner**: {}\n\
|
||||
- **Status**: backlog\n\
|
||||
",
|
||||
- **Owner**: {}\n\
|
||||
- **Created At**: {}\n\
|
||||
- **Status**: backlog\n\
|
||||
",
|
||||
title,
|
||||
description_text,
|
||||
if acceptance.is_empty() {
|
||||
@@ -250,6 +284,7 @@ fn cmd_add(
|
||||
},
|
||||
due.as_deref().unwrap_or("_Not set_"),
|
||||
owner.as_deref().unwrap_or("_Not set_"),
|
||||
Local::now().format("%Y-%m-%d %H:%M:%S"),
|
||||
);
|
||||
body.push('\n');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user