refactor(hive-forge): port CLI verbs to forgejo-api

This commit is contained in:
müde 2026-07-07 09:24:53 +02:00
commit 4636987469
36 changed files with 1463 additions and 1153 deletions

View file

@ -8,7 +8,7 @@ use anyhow::Result;
use clap::Args as ClapArgs;
use serde_json::json;
use crate::client::Client;
use crate::client::{Client, index};
use crate::verbs::print_json;
#[derive(ClapArgs)]
@ -20,16 +20,21 @@ pub struct Args {
/// # Errors
///
/// Returns an error when the `PATCH /repos/{repo}/issues/{number}` request
/// fails (network / non-success status from `patch_json`) or when emitting
/// the JSON summary via `print_json` fails.
/// fails (network / non-success status) or when emitting the JSON summary
/// via `print_json` fails.
pub fn run(client: &Client, args: Args) -> Result<()> {
let repo = client.repo();
let resp = client.patch_json(
&format!("/repos/{repo}/issues/{}", args.number),
&json!({ "state": "open" }),
)?;
let (owner, name) = client.owner_repo()?;
let resp = client
.api()
.issue_edit_issue(
owner,
name,
index(args.number)?,
super::close::state_edit("open"),
)
.send()?;
print_json(&json!({
"number": resp.get("number"),
"state": resp.get("state"),
"number": resp.number,
"state": resp.state,
}))
}