(bdfd5f2) Apply color guidelines to codebase

This commit is contained in:
2026-05-15 19:11:05 +02:00
parent 75e9ea2309
commit 2a96abd3b0
4 changed files with 55 additions and 21 deletions
+1 -1
View File
@@ -83,7 +83,7 @@ Add a comment to the ticket using `worklane comment` with the following structur
**Ratings:**
- Code Quality: Rate the overall code quality (1-10) based on the four dimensions above
- Acceptance Criteria Match: Rate how well the implementation fulfills all acceptance criteria (1-10)
- Use `worklane comment <ticket-id-or-title> "<comment>"` to add the comment (escape any special characters in the comment body)
- Use `worklane comment -o ReviewBot <ticket-id-or-title> "<comment>"` to add the comment (escape any special characters in the comment body)
### 6. Recommend next steps
+7
View File
@@ -38,6 +38,13 @@
- Bold uses `\x1b[1;35m` (magenta bold)
- Always test color output works correctly in both terminal and pipe modes
### Color Guideline
- UUID → red (31)
- Status → orange (33)
- Timestamp → cyan (36)
- Title → green (32)
- Unknown values (`_None_`, `_Not set_`) → grey (90)
### Code Organization
- Colorization functions (`colorize_line`, `colorize_metadata`, `colorize_ordered`, `content_trim_colored`) handle markdown formatting
- `resolve_ticket()` scans all status directories — it's the single source for ticket lookup by UUID prefix, title, or filename
+24 -7
View File
@@ -62,8 +62,11 @@ pub fn cmd_ls(status_filter: &Option<String>, worklane_dir: &Path) -> Result<()>
println!(" [{}] {} {}", status.to_uppercase(), count, label);
}
// Show all tickets grouped by status
// Show all tickets except done grouped by status
for status in &statuses {
if *status == "done" {
continue;
}
let status_path = worklane_dir.join(status);
if !status_path.exists() || !fs::metadata(&status_path)?.is_dir() {
continue;
@@ -178,6 +181,7 @@ pub fn cmd_add(
println!("Created ticket: {}", filename);
Ok(())
}
fn read_comments(comments_dir: &Path) -> Result<Vec<(String, String, String, String)>> {
if !comments_dir.exists() {
return Ok(vec![]);
@@ -273,8 +277,8 @@ pub fn cmd_mv(ticket_id: &str, target_status: &str, force: bool, start: &Path) -
if !force && target_idx < current_idx {
return Err(anyhow!(
"Cannot move backward from {} to {}. Use --force (-f) to allow.",
current_status,
target_status
color_text(&current_status, "orange"),
color_text(target_status, "orange"),
));
}
@@ -285,7 +289,10 @@ pub fn cmd_mv(ticket_id: &str, target_status: &str, force: bool, start: &Path) -
}
if current_status == target_status {
println!("Ticket is already in '{}' status.", target_status);
println!(
"Ticket is already in '{}' status.",
color_text(&target_status, "orange")
);
return Ok(());
}
@@ -313,7 +320,10 @@ pub fn cmd_mv(ticket_id: &str, target_status: &str, force: bool, start: &Path) -
}
if found_filename.is_empty() {
return Err(anyhow!("Could not find ticket file in {}", current_status));
return Err(anyhow!(
"Could not find ticket file in {}",
color_text(&current_status, "orange")
));
}
// Read and update the ticket content
@@ -345,13 +355,20 @@ pub fn cmd_mv(ticket_id: &str, target_status: &str, force: bool, start: &Path) -
println!(
"Moved ticket '{}' from {} to {}",
title, current_status, target_status
color_text(&title, "green"),
color_text(&current_status, "orange"),
color_text(target_status, "orange"),
);
Ok(())
}
pub fn cmd_comment(ticket_id: &str, body: &str, owner: &Option<String>, start: &Path) -> Result<()> {
pub fn cmd_comment(
ticket_id: &str,
body: &str,
owner: &Option<String>,
start: &Path,
) -> Result<()> {
if body.is_empty() {
return Err(anyhow!("Comment body is required."));
}
+23 -13
View File
@@ -172,7 +172,7 @@ pub fn content_trim_colored(content: &str) -> String {
if line.starts_with("## ") {
current_section = line;
let section_name = &line[3..];
result.push_str(&format!("\x1b[33m{}\x1b[0m", section_name));
result.push_str(&color_text(section_name, "orange"));
result.push('\n');
result.push_str(&"─".repeat(line.len()));
result.push('\n');
@@ -183,7 +183,7 @@ pub fn content_trim_colored(content: &str) -> String {
// First line is the title header - color it in green
if line.starts_with("# ") && current_section.is_empty() {
let header = &line[2..]; // Remove "# "
result.push_str(&format!("\x1b[32m{}\x1b[0m", header));
result.push_str(&color_text(header, "green"));
result.push('\n');
continue;
}
@@ -204,7 +204,7 @@ pub fn content_trim_colored(content: &str) -> String {
// Acceptance Criteria checkboxes
if line.starts_with("- [ ]") {
result.push_str("\x1b[90m- [ ]\x1b[0m");
result.push_str(&color_text("- [ ]", "grey"));
result.push_str(&line[5..]);
result.push('\n');
continue;
@@ -218,9 +218,7 @@ pub fn content_trim_colored(content: &str) -> String {
let link_start = start + end_bracket + 1;
if let Some(end) = line[link_start..].find(']') {
let absolute_end = link_start + end + 1;
result.push_str("\x1b[36m");
result.push_str(&line[start..absolute_end]);
result.push_str("\x1b[0m");
result.push_str(&color_text(&line[start..absolute_end], "cyan"));
result.push('\n');
continue;
}
@@ -250,7 +248,7 @@ pub fn colorize_ordered(line: &str) -> String {
// still scanning digits
} else if *c == '.' && i + 1 < chars.len() && chars[i + 1] == ' ' {
let number = &line[..i + 1];
result.push_str(&format!("\x1b[36m{}\x1b[0m", number));
result.push_str(&color_text(number, "cyan"));
result.push_str(&line[i + 1..]);
return result;
} else {
@@ -282,13 +280,25 @@ pub fn colorize_metadata(line: &str) -> String {
let field_name = &content[after_open..after_open + close_pos];
let after_field = &content[after_open + close_pos + 2..];
let colored_field = color_text(field_name, "red");
let value_text = after_field.strip_prefix(": ").map(|s| s.trim()).unwrap_or(after_field);
let after_field_colored = if is_unknown_value(value_text) {
color_text(after_field, "grey")
} else {
after_field.to_string()
};
format!(
"{}{}{}{}",
"{}{}{}",
&content[..open_pos],
"\x1b[31m",
field_name,
"\x1b[0m"
) + after_field
colored_field,
after_field_colored
)
}
pub fn is_unknown_value(value: &str) -> bool {
let trimmed = value.trim();
trimmed == "_None_" || trimmed == "_Not set_" || trimmed == "-None-" || trimmed == "-Not set-"
}
pub fn colorize_line(line: &str) -> String {
@@ -311,7 +321,7 @@ pub fn colorize_line(line: &str) -> String {
}
let bold_text: String = chars[start..end].iter().collect();
result.push_str(&format!("\x1b[1;35m{}\x1b[0m", bold_text));
result.push_str(&color_text(&bold_text, "magenta"));
i = end + 2;
continue;
}