//! `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, index}; 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) or when emitting the JSON summary /// via `print_json` fails. pub fn run(client: &Client, args: Args) -> Result<()> { 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.number, "state": resp.state, })) }