Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion adapters/weread/shelf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ pipeline:
return books.slice(0, limit).map(item => ({
title: item.title || '',
author: item.author || '',
cover: item.cover || '',
progress: progressMap[item.bookId] != null ? progressMap[item.bookId] + '%' : '-',
bookId: item.bookId || '',
}));
})()

columns: [title, author, progress, bookId]
columns: [title, author, cover, progress, bookId]
32 changes: 26 additions & 6 deletions crates/opencli-rs-output/src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,14 @@ pub fn render(data: &Value, opts: &RenderOptions) -> String {
output = format!("{}\n{}", title, output);
}

if let Some(footer) = build_footer(opts) {
if !output.ends_with('\n') {
output.push('\n');
// Only show footer for human-readable formats (Table, Markdown)
if matches!(opts.format, OutputFormat::Table | OutputFormat::Markdown) {
if let Some(footer) = build_footer(opts) {
if !output.ends_with('\n') {
output.push('\n');
}
output.push_str(&footer);
}
output.push_str(&footer);
}

output
Expand Down Expand Up @@ -92,9 +95,10 @@ mod tests {

#[test]
fn test_render_with_footer() {
// Footer should only appear in Table/Markdown format, not in JSON
let data = json!({"name": "Alice"});
let opts = RenderOptions {
format: OutputFormat::Json,
format: OutputFormat::Table,
elapsed: Some(Duration::from_millis(150)),
source: Some("test-api".to_string()),
footer_extra: Some("page 1/3".to_string()),
Expand All @@ -106,6 +110,22 @@ mod tests {
assert!(out.contains("page 1/3"));
}

#[test]
fn test_render_json_no_footer() {
// JSON format should not have footer
let data = json!({"name": "Alice"});
let opts = RenderOptions {
format: OutputFormat::Json,
elapsed: Some(Duration::from_millis(150)),
source: Some("test-api".to_string()),
..Default::default()
};
let out = render(&data, &opts);
assert!(!out.contains("Elapsed:"));
assert!(!out.contains("Source:"));
assert!(out.contains("Alice"));
}

#[test]
fn test_render_with_title() {
let data = json!([{"name": "Alice"}]);
Expand All @@ -122,7 +142,7 @@ mod tests {
fn test_render_elapsed_seconds() {
let data = json!("ok");
let opts = RenderOptions {
format: OutputFormat::Json,
format: OutputFormat::Table,
elapsed: Some(Duration::from_secs_f64(2.5)),
..Default::default()
};
Expand Down