hive-forge: make --json a global flag (closes #421)
This commit is contained in:
parent
3cd9240594
commit
d0a1ee037b
5 changed files with 33 additions and 16 deletions
|
|
@ -1,5 +1,5 @@
|
|||
//! `comment-show <id> [--json] [repo]` — print the body (or full
|
||||
//! JSON) of a single comment by id.
|
||||
//! `comment-show <id>` — print the body (or full JSON envelope
|
||||
//! when `--json` is set globally) of a single comment by id.
|
||||
|
||||
use anyhow::Result;
|
||||
use clap::Args as ClapArgs;
|
||||
|
|
@ -12,15 +12,12 @@ use crate::verbs::print_json;
|
|||
pub struct Args {
|
||||
/// Comment id.
|
||||
id: u64,
|
||||
/// Print full JSON envelope instead of just the body text.
|
||||
#[arg(long)]
|
||||
json: bool,
|
||||
}
|
||||
|
||||
pub fn run(client: &Client, args: Args) -> Result<()> {
|
||||
let repo = client.repo();
|
||||
let v = client.get_json(&format!("/repos/{repo}/issues/comments/{}", args.id))?;
|
||||
if args.json {
|
||||
if client.json_mode() {
|
||||
let trimmed = json!({
|
||||
"id": v.get("id"),
|
||||
"user": v.get("user").and_then(|u| u.get("login")),
|
||||
|
|
|
|||
Loading…
Reference in a new issue