hive-forge: make --json a global flag (closes #421)

This commit is contained in:
damocles 2026-05-26 14:36:00 +02:00 committed by Mara
commit d0a1ee037b
5 changed files with 33 additions and 16 deletions

View file

@ -1,5 +1,6 @@
//! `comments <number> [--json] [--limit N]` — list all comments on
//! an issue or PR. Closes the curl-fallback gap (#418).
//! `comments <number> [--limit N]` — list all comments on an issue
//! or PR. Closes the curl-fallback gap (#418). Use the global
//! `--json` flag for JSON output (#421).
use anyhow::Result;
use clap::Args as ClapArgs;
@ -12,9 +13,6 @@ use crate::verbs::print_json;
pub struct Args {
/// Issue or PR number.
number: u64,
/// Print as JSON array instead of human-readable markdown.
#[arg(long)]
json: bool,
/// Page size (Forgejo caps at 50 by default).
#[arg(long, default_value_t = 50)]
limit: u64,
@ -26,7 +24,7 @@ pub fn run(client: &Client, args: Args) -> Result<()> {
"/repos/{repo}/issues/{}/comments?limit={}",
args.number, args.limit
))?;
if args.json {
if client.json_mode() {
let trimmed: Vec<Value> = v
.as_array()
.map(|a| {