diff --git a/src/commands/bugs.rs b/src/commands/bugs.rs index 08d318f..affe33e 100644 --- a/src/commands/bugs.rs +++ b/src/commands/bugs.rs @@ -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 } => { diff --git a/src/commands/repos.rs b/src/commands/repos.rs index bfbc8df..57d0501 100644 --- a/src/commands/repos.rs +++ b/src/commands/repos.rs @@ -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) } } } diff --git a/src/output.rs b/src/output.rs index 73d694a..33108b9 100644 --- a/src/output.rs +++ b/src/output.rs @@ -23,13 +23,19 @@ pub trait Formattable { pub fn output_list( 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)?); } @@ -49,7 +55,7 @@ pub fn output_list( table.add_row(Row::new(item.to_table_row())); } table.printstd(); - println!("\nTotal: {}", total); + println!("\nPage: {} of {}", page, total_pages); } } Ok(())