//! `reopen ` — reopen a closed issue or PR. //! //! Mirror of `close`: sends a PATCH setting the issue/PR `state` back to //! `open`. PRs share the issue number space, so the same `/issues/` //! endpoint reopens either. use anyhow::Result; use clap::Args as ClapArgs; use serde_json::json; use crate::client::Client; use crate::verbs::print_json; #[derive(ClapArgs)] pub struct Args { /// Issue or PR number. pub(crate) number: u64, } /// # 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. 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" }), )?; print_json(&json!({ "number": resp.get("number"), "state": resp.get("state"), })) }