(bdfd5f2) Apply color guidelines to codebase
This commit is contained in:
@@ -83,7 +83,7 @@ Add a comment to the ticket using `worklane comment` with the following structur
|
|||||||
**Ratings:**
|
**Ratings:**
|
||||||
- Code Quality: Rate the overall code quality (1-10) based on the four dimensions above
|
- 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)
|
- 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
|
### 6. Recommend next steps
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,13 @@
|
|||||||
- Bold uses `\x1b[1;35m` (magenta bold)
|
- Bold uses `\x1b[1;35m` (magenta bold)
|
||||||
- Always test color output works correctly in both terminal and pipe modes
|
- 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
|
### Code Organization
|
||||||
- Colorization functions (`colorize_line`, `colorize_metadata`, `colorize_ordered`, `content_trim_colored`) handle markdown formatting
|
- 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
|
- `resolve_ticket()` scans all status directories — it's the single source for ticket lookup by UUID prefix, title, or filename
|
||||||
|
|||||||
+24
-7
@@ -62,8 +62,11 @@ pub fn cmd_ls(status_filter: &Option<String>, worklane_dir: &Path) -> Result<()>
|
|||||||
println!(" [{}] {} {}", status.to_uppercase(), count, label);
|
println!(" [{}] {} {}", status.to_uppercase(), count, label);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show all tickets grouped by status
|
// Show all tickets except done grouped by status
|
||||||
for status in &statuses {
|
for status in &statuses {
|
||||||
|
if *status == "done" {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
let status_path = worklane_dir.join(status);
|
let status_path = worklane_dir.join(status);
|
||||||
if !status_path.exists() || !fs::metadata(&status_path)?.is_dir() {
|
if !status_path.exists() || !fs::metadata(&status_path)?.is_dir() {
|
||||||
continue;
|
continue;
|
||||||
@@ -178,6 +181,7 @@ pub fn cmd_add(
|
|||||||
println!("Created ticket: {}", filename);
|
println!("Created ticket: {}", filename);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_comments(comments_dir: &Path) -> Result<Vec<(String, String, String, String)>> {
|
fn read_comments(comments_dir: &Path) -> Result<Vec<(String, String, String, String)>> {
|
||||||
if !comments_dir.exists() {
|
if !comments_dir.exists() {
|
||||||
return Ok(vec![]);
|
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 {
|
if !force && target_idx < current_idx {
|
||||||
return Err(anyhow!(
|
return Err(anyhow!(
|
||||||
"Cannot move backward from {} to {}. Use --force (-f) to allow.",
|
"Cannot move backward from {} to {}. Use --force (-f) to allow.",
|
||||||
current_status,
|
color_text(¤t_status, "orange"),
|
||||||
target_status
|
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 {
|
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(());
|
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() {
|
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(¤t_status, "orange")
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read and update the ticket content
|
// 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!(
|
println!(
|
||||||
"Moved ticket '{}' from {} to {}",
|
"Moved ticket '{}' from {} to {}",
|
||||||
title, current_status, target_status
|
color_text(&title, "green"),
|
||||||
|
color_text(¤t_status, "orange"),
|
||||||
|
color_text(target_status, "orange"),
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(())
|
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() {
|
if body.is_empty() {
|
||||||
return Err(anyhow!("Comment body is required."));
|
return Err(anyhow!("Comment body is required."));
|
||||||
}
|
}
|
||||||
|
|||||||
+23
-13
@@ -172,7 +172,7 @@ pub fn content_trim_colored(content: &str) -> String {
|
|||||||
if line.starts_with("## ") {
|
if line.starts_with("## ") {
|
||||||
current_section = line;
|
current_section = line;
|
||||||
let section_name = &line[3..];
|
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('\n');
|
||||||
result.push_str(&"─".repeat(line.len()));
|
result.push_str(&"─".repeat(line.len()));
|
||||||
result.push('\n');
|
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
|
// First line is the title header - color it in green
|
||||||
if line.starts_with("# ") && current_section.is_empty() {
|
if line.starts_with("# ") && current_section.is_empty() {
|
||||||
let header = &line[2..]; // Remove "# "
|
let header = &line[2..]; // Remove "# "
|
||||||
result.push_str(&format!("\x1b[32m{}\x1b[0m", header));
|
result.push_str(&color_text(header, "green"));
|
||||||
result.push('\n');
|
result.push('\n');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -204,7 +204,7 @@ pub fn content_trim_colored(content: &str) -> String {
|
|||||||
|
|
||||||
// Acceptance Criteria checkboxes
|
// Acceptance Criteria checkboxes
|
||||||
if line.starts_with("- [ ]") {
|
if line.starts_with("- [ ]") {
|
||||||
result.push_str("\x1b[90m- [ ]\x1b[0m");
|
result.push_str(&color_text("- [ ]", "grey"));
|
||||||
result.push_str(&line[5..]);
|
result.push_str(&line[5..]);
|
||||||
result.push('\n');
|
result.push('\n');
|
||||||
continue;
|
continue;
|
||||||
@@ -218,9 +218,7 @@ pub fn content_trim_colored(content: &str) -> String {
|
|||||||
let link_start = start + end_bracket + 1;
|
let link_start = start + end_bracket + 1;
|
||||||
if let Some(end) = line[link_start..].find(']') {
|
if let Some(end) = line[link_start..].find(']') {
|
||||||
let absolute_end = link_start + end + 1;
|
let absolute_end = link_start + end + 1;
|
||||||
result.push_str("\x1b[36m");
|
result.push_str(&color_text(&line[start..absolute_end], "cyan"));
|
||||||
result.push_str(&line[start..absolute_end]);
|
|
||||||
result.push_str("\x1b[0m");
|
|
||||||
result.push('\n');
|
result.push('\n');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -250,7 +248,7 @@ pub fn colorize_ordered(line: &str) -> String {
|
|||||||
// still scanning digits
|
// still scanning digits
|
||||||
} else if *c == '.' && i + 1 < chars.len() && chars[i + 1] == ' ' {
|
} else if *c == '.' && i + 1 < chars.len() && chars[i + 1] == ' ' {
|
||||||
let number = &line[..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..]);
|
result.push_str(&line[i + 1..]);
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
@@ -282,13 +280,25 @@ pub fn colorize_metadata(line: &str) -> String {
|
|||||||
let field_name = &content[after_open..after_open + close_pos];
|
let field_name = &content[after_open..after_open + close_pos];
|
||||||
let after_field = &content[after_open + close_pos + 2..];
|
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!(
|
format!(
|
||||||
"{}{}{}{}",
|
"{}{}{}",
|
||||||
&content[..open_pos],
|
&content[..open_pos],
|
||||||
"\x1b[31m",
|
colored_field,
|
||||||
field_name,
|
after_field_colored
|
||||||
"\x1b[0m"
|
)
|
||||||
) + after_field
|
}
|
||||||
|
|
||||||
|
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 {
|
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();
|
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;
|
i = end + 2;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user