refactor(notes): remove csv and jsonl output formats
Remove print_list_notes_csv, print_list_notes_jsonl, and csv_escape from the notes list command. The --format flag's csv and jsonl variants added complexity without meaningful adoption — robot mode already provides structured JSON output. Notes now have two output paths: human (default) and JSON (--robot). Also removes the corresponding test coverage (csv_escape, csv_output). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -980,59 +980,6 @@ pub fn print_list_notes_json(result: &NoteListResult, elapsed_ms: u64, fields: O
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print_list_notes_jsonl(result: &NoteListResult) {
|
||||
for note in &result.notes {
|
||||
let json_row = NoteListRowJson::from(note);
|
||||
match serde_json::to_string(&json_row) {
|
||||
Ok(json) => println!("{json}"),
|
||||
Err(e) => eprintln!("Error serializing to JSON: {e}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Escape a field for RFC 4180 CSV: quote fields containing commas, quotes, or newlines.
|
||||
fn csv_escape(field: &str) -> String {
|
||||
if field.contains(',') || field.contains('"') || field.contains('\n') || field.contains('\r') {
|
||||
let escaped = field.replace('"', "\"\"");
|
||||
format!("\"{escaped}\"")
|
||||
} else {
|
||||
field.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print_list_notes_csv(result: &NoteListResult) {
|
||||
println!(
|
||||
"id,gitlab_id,author_username,body,note_type,is_system,created_at,updated_at,position_new_path,position_new_line,noteable_type,parent_iid,project_path"
|
||||
);
|
||||
for note in &result.notes {
|
||||
let body = note.body.as_deref().unwrap_or("");
|
||||
let note_type = note.note_type.as_deref().unwrap_or("");
|
||||
let path = note.position_new_path.as_deref().unwrap_or("");
|
||||
let line = note
|
||||
.position_new_line
|
||||
.map_or(String::new(), |l| l.to_string());
|
||||
let noteable = note.noteable_type.as_deref().unwrap_or("");
|
||||
let parent_iid = note.parent_iid.map_or(String::new(), |i| i.to_string());
|
||||
|
||||
println!(
|
||||
"{},{},{},{},{},{},{},{},{},{},{},{},{}",
|
||||
note.id,
|
||||
note.gitlab_id,
|
||||
csv_escape(¬e.author_username),
|
||||
csv_escape(body),
|
||||
csv_escape(note_type),
|
||||
note.is_system,
|
||||
note.created_at,
|
||||
note.updated_at,
|
||||
csv_escape(path),
|
||||
line,
|
||||
csv_escape(noteable),
|
||||
parent_iid,
|
||||
csv_escape(¬e.project_path),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Note query layer
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user