From ad6c39abdc35603f58e9b71993b5632c976deac1 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 5 Mar 2026 12:12:21 +0000 Subject: feat(status): add --reason to all pr and issue status commands All status transitions (pr close/reopen/ready/draft, issue close/reopen/ resolved) now accept an optional --reason flag stored in the event content. --- src/bin/ngit/cli.rs | 15 +++++++++++++++ src/bin/ngit/main.rs | 20 ++++++++++---------- src/bin/ngit/sub_commands/issue_status.rs | 4 ++-- src/bin/ngit/sub_commands/pr_status.rs | 16 ++++++++-------- 4 files changed, 35 insertions(+), 20 deletions(-) (limited to 'src/bin') diff --git a/src/bin/ngit/cli.rs b/src/bin/ngit/cli.rs index 37d85a2..a240597 100644 --- a/src/bin/ngit/cli.rs +++ b/src/bin/ngit/cli.rs @@ -248,6 +248,9 @@ pub enum PrCommands { /// Proposal event-id (hex) or nevent (bech32) #[arg(value_name = "ID|nevent")] id: String, + /// Optional reason stored in event content + #[arg(long)] + reason: Option, /// Use local cache only, skip network fetch #[arg(long)] offline: bool, @@ -257,6 +260,9 @@ pub enum PrCommands { /// Proposal event-id (hex) or nevent (bech32) #[arg(value_name = "ID|nevent")] id: String, + /// Optional reason stored in event content + #[arg(long)] + reason: Option, /// Use local cache only, skip network fetch #[arg(long)] offline: bool, @@ -266,6 +272,9 @@ pub enum PrCommands { /// Proposal event-id (hex) or nevent (bech32) #[arg(value_name = "ID|nevent")] id: String, + /// Optional reason stored in event content + #[arg(long)] + reason: Option, /// Use local cache only, skip network fetch #[arg(long)] offline: bool, @@ -275,6 +284,9 @@ pub enum PrCommands { /// Proposal event-id (hex) or nevent (bech32) #[arg(value_name = "ID|nevent")] id: String, + /// Optional reason stored in event content + #[arg(long)] + reason: Option, /// Use local cache only, skip network fetch #[arg(long)] offline: bool, @@ -414,6 +426,9 @@ pub enum IssueCommands { /// Issue event-id (hex) or nevent (bech32) #[arg(value_name = "ID|nevent")] id: String, + /// Optional reason stored in event content + #[arg(long)] + reason: Option, /// Use local cache only, skip network fetch #[arg(long)] offline: bool, diff --git a/src/bin/ngit/main.rs b/src/bin/ngit/main.rs index a0cb3e6..3686011 100644 --- a/src/bin/ngit/main.rs +++ b/src/bin/ngit/main.rs @@ -102,17 +102,17 @@ async fn main() { PrCommands::Send(sub_args) => { sub_commands::send::launch(&cli, sub_args, false).await } - PrCommands::Close { id, offline } => { - sub_commands::pr_status::launch_close(id, *offline).await + PrCommands::Close { id, reason, offline } => { + sub_commands::pr_status::launch_close(id, *offline, reason.as_deref()).await } - PrCommands::Reopen { id, offline } => { - sub_commands::pr_status::launch_reopen(id, *offline).await + PrCommands::Reopen { id, reason, offline } => { + sub_commands::pr_status::launch_reopen(id, *offline, reason.as_deref()).await } - PrCommands::Ready { id, offline } => { - sub_commands::pr_status::launch_ready(id, *offline).await + PrCommands::Ready { id, reason, offline } => { + sub_commands::pr_status::launch_ready(id, *offline, reason.as_deref()).await } - PrCommands::Draft { id, offline } => { - sub_commands::pr_status::launch_draft(id, *offline).await + PrCommands::Draft { id, reason, offline } => { + sub_commands::pr_status::launch_draft(id, *offline, reason.as_deref()).await } PrCommands::Comment { id, @@ -188,8 +188,8 @@ async fn main() { sub_commands::issue_status::launch_resolved(id, *offline, reason.as_deref()) .await } - IssueCommands::Reopen { id, offline } => { - sub_commands::issue_status::launch_reopen(id, *offline).await + IssueCommands::Reopen { id, reason, offline } => { + sub_commands::issue_status::launch_reopen(id, *offline, reason.as_deref()).await } IssueCommands::Comment { id, diff --git a/src/bin/ngit/sub_commands/issue_status.rs b/src/bin/ngit/sub_commands/issue_status.rs index 840ab8e..99b4fa6 100644 --- a/src/bin/ngit/sub_commands/issue_status.rs +++ b/src/bin/ngit/sub_commands/issue_status.rs @@ -183,8 +183,8 @@ pub async fn launch_close(id: &str, offline: bool, reason: Option<&str>) -> Resu launch_status(id, offline, Kind::GitStatusClosed, "closed", reason).await } -pub async fn launch_reopen(id: &str, offline: bool) -> Result<()> { - launch_status(id, offline, Kind::GitStatusOpen, "reopened", None).await +pub async fn launch_reopen(id: &str, offline: bool, reason: Option<&str>) -> Result<()> { + launch_status(id, offline, Kind::GitStatusOpen, "reopened", reason).await } pub async fn launch_resolved(id: &str, offline: bool, reason: Option<&str>) -> Result<()> { diff --git a/src/bin/ngit/sub_commands/pr_status.rs b/src/bin/ngit/sub_commands/pr_status.rs index 12aafb7..4a51bb3 100644 --- a/src/bin/ngit/sub_commands/pr_status.rs +++ b/src/bin/ngit/sub_commands/pr_status.rs @@ -193,18 +193,18 @@ async fn launch_status( Ok(()) } -pub async fn launch_close(id: &str, offline: bool) -> Result<()> { - launch_status(id, offline, Kind::GitStatusClosed, "closed", None).await +pub async fn launch_close(id: &str, offline: bool, reason: Option<&str>) -> Result<()> { + launch_status(id, offline, Kind::GitStatusClosed, "closed", reason).await } -pub async fn launch_reopen(id: &str, offline: bool) -> Result<()> { - launch_status(id, offline, Kind::GitStatusOpen, "reopened", None).await +pub async fn launch_reopen(id: &str, offline: bool, reason: Option<&str>) -> Result<()> { + launch_status(id, offline, Kind::GitStatusOpen, "reopened", reason).await } -pub async fn launch_ready(id: &str, offline: bool) -> Result<()> { - launch_status(id, offline, Kind::GitStatusOpen, "marked as ready", None).await +pub async fn launch_ready(id: &str, offline: bool, reason: Option<&str>) -> Result<()> { + launch_status(id, offline, Kind::GitStatusOpen, "marked as ready", reason).await } -pub async fn launch_draft(id: &str, offline: bool) -> Result<()> { - launch_status(id, offline, Kind::GitStatusDraft, "converted to draft", None).await +pub async fn launch_draft(id: &str, offline: bool, reason: Option<&str>) -> Result<()> { + launch_status(id, offline, Kind::GitStatusDraft, "converted to draft", reason).await } -- cgit v1.2.3