upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/bin/ngit/main.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2026-03-04 14:28:38 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2026-03-04 14:50:01 +0000
commitb3b1a949463d8e18622519866ecee3f1b65cc888 (patch)
tree9c728adb75fb18cb84e8d13efbbbd5e90231ec2f /src/bin/ngit/main.rs
parent6d9b0cc8fff65447849d0d55db177dcdff315c48 (diff)
restructure CLI around ngit pr/issue subcommand groups
Introduce ngit pr subcommand group (list, view, checkout, apply, send, close, reopen, ready, comment, merge) replacing the former top-level ngit list/checkout/apply commands. ngit send is kept at the top level. Expand ngit issue with view, create, close, reopen, comment subcommands. Status changes (close/reopen/ready) are gated to the PR/issue author or a repository maintainer. ngit pr merge is maintainer-only and publishes a GitStatusApplied event immediately after the git merge.
Diffstat (limited to 'src/bin/ngit/main.rs')
-rw-r--r--src/bin/ngit/main.rs91
1 files changed, 75 insertions, 16 deletions
diff --git a/src/bin/ngit/main.rs b/src/bin/ngit/main.rs
index cb0cc52..2982b61 100644
--- a/src/bin/ngit/main.rs
+++ b/src/bin/ngit/main.rs
@@ -3,7 +3,7 @@
3#![cfg_attr(not(test), warn(clippy::expect_used))] 3#![cfg_attr(not(test), warn(clippy::expect_used))]
4 4
5use clap::Parser; 5use clap::Parser;
6use cli::{AccountCommands, CUSTOMISE_TEMPLATE, Cli, Commands, IssueCommands}; 6use cli::{AccountCommands, CUSTOMISE_TEMPLATE, Cli, Commands, IssueCommands, PrCommands};
7 7
8mod cli; 8mod cli;
9use ngit::{ 9use ngit::{
@@ -16,6 +16,7 @@ use ngit::{
16mod sub_commands; 16mod sub_commands;
17 17
18#[tokio::main] 18#[tokio::main]
19#[allow(clippy::too_many_lines)]
19async fn main() { 20async fn main() {
20 let cli = Cli::parse(); 21 let cli = Cli::parse();
21 22
@@ -52,12 +53,52 @@ async fn main() {
52 Commands::Repo(args) => { 53 Commands::Repo(args) => {
53 sub_commands::repo::launch(&cli, args.repo_command.as_ref(), args.offline).await 54 sub_commands::repo::launch(&cli, args.repo_command.as_ref(), args.offline).await
54 } 55 }
55 Commands::List { 56 Commands::Send(args) => sub_commands::send::launch(&cli, args, false).await,
56 status, 57 Commands::Pr(args) => match &args.pr_command {
57 json, 58 PrCommands::List {
58 id, 59 status,
59 offline, 60 json,
60 } => sub_commands::list::launch(status.clone(), *json, id.clone(), *offline).await, 61 id,
62 offline,
63 } => sub_commands::list::launch(status.clone(), *json, id.clone(), *offline).await,
64 PrCommands::View { id, json, offline } => {
65 sub_commands::list::launch(
66 "open,draft,closed,applied".to_string(),
67 *json,
68 Some(id.clone()),
69 *offline,
70 )
71 .await
72 }
73 PrCommands::Checkout { id, offline } => {
74 sub_commands::checkout::launch(id, *offline).await
75 }
76 PrCommands::Apply {
77 id,
78 stdout,
79 offline,
80 } => sub_commands::apply::launch(id, *stdout, *offline).await,
81 PrCommands::Send(sub_args) => {
82 sub_commands::send::launch(&cli, sub_args, false).await
83 }
84 PrCommands::Close { id, offline } => {
85 sub_commands::pr_status::launch_close(id, *offline).await
86 }
87 PrCommands::Reopen { id, offline } => {
88 sub_commands::pr_status::launch_reopen(id, *offline).await
89 }
90 PrCommands::Ready { id, offline } => {
91 sub_commands::pr_status::launch_ready(id, *offline).await
92 }
93 PrCommands::Comment { id, body, offline } => {
94 sub_commands::comment::launch_pr_comment(id, body, *offline).await
95 }
96 PrCommands::Merge {
97 id,
98 squash,
99 offline,
100 } => sub_commands::pr_merge::launch(id, *squash, *offline).await,
101 },
61 Commands::Issue(args) => match &args.issue_command { 102 Commands::Issue(args) => match &args.issue_command {
62 IssueCommands::List { 103 IssueCommands::List {
63 status, 104 status,
@@ -75,17 +116,35 @@ async fn main() {
75 ) 116 )
76 .await 117 .await
77 } 118 }
119 IssueCommands::View { id, json, offline } => {
120 sub_commands::issue_list::launch(
121 "open,draft,closed,applied".to_string(),
122 None,
123 *json,
124 Some(id.clone()),
125 *offline,
126 )
127 .await
128 }
129 IssueCommands::Create {
130 title,
131 body,
132 labels,
133 } => {
134 sub_commands::issue_create::launch(title.clone(), body.clone(), labels.clone())
135 .await
136 }
137 IssueCommands::Close { id, offline } => {
138 sub_commands::issue_status::launch_close(id, *offline).await
139 }
140 IssueCommands::Reopen { id, offline } => {
141 sub_commands::issue_status::launch_reopen(id, *offline).await
142 }
143 IssueCommands::Comment { id, body, offline } => {
144 sub_commands::comment::launch_issue_comment(id, body, *offline).await
145 }
78 }, 146 },
79 Commands::Send(args) => sub_commands::send::launch(&cli, args, false).await,
80 Commands::Sync(args) => sub_commands::sync::launch(args).await, 147 Commands::Sync(args) => sub_commands::sync::launch(args).await,
81 Commands::Checkout { id, offline } => {
82 sub_commands::checkout::launch(id, *offline).await
83 }
84 Commands::Apply {
85 id,
86 stdout,
87 offline,
88 } => sub_commands::apply::launch(id, *stdout, *offline).await,
89 } 148 }
90 } else { 149 } else {
91 // Show help when no command is provided 150 // Show help when no command is provided