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
2 changes: 1 addition & 1 deletion src/commands/bugs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ pub async fn handle(command: &BugCommands, cli: &crate::Cli) -> Result<()> {
.await
.context("Failed to fetch bugs from repository")?;

crate::output::output_list(&bugs.bugs, bugs.total, format)
crate::output::output_list(&bugs.bugs, bugs.total, *page, *limit, format)
}

BugCommands::Show { bug_id } => {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/repos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub async fn handle(command: &RepoCommands, cli: &crate::Cli) -> Result<()> {
let repos = client.list_repos(*limit, offset).await
.context("Failed to fetch repositories")?;

crate::output::output_list(&repos.repos, repos.total, format)
crate::output::output_list(&repos.repos, repos.total, *page, *limit, format)
}
}
}
8 changes: 7 additions & 1 deletion src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,19 @@ pub trait Formattable {
pub fn output_list<T: Formattable + Serialize>(
items: &[T],
total: usize,
page: u32,
limit: u32,
format: &crate::OutputFormat,
) -> Result<()> {
let total_pages = (total as u32).div_ceil(limit).max(1);

match format {
crate::OutputFormat::Json => {
let response = serde_json::json!({
"items": items,
"total": total,
"page": page,
"total_pages": total_pages,
});
println!("{}", serde_json::to_string_pretty(&response)?);
}
Expand All @@ -49,7 +55,7 @@ pub fn output_list<T: Formattable + Serialize>(
table.add_row(Row::new(item.to_table_row()));
}
table.printstd();
println!("\nTotal: {}", total);
println!("\nPage: {} of {}", page, total_pages);
}
}
Ok(())
Expand Down