upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/bin/ngit
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/ngit')
-rw-r--r--src/bin/ngit/cli.rs6
-rw-r--r--src/bin/ngit/main.rs4
-rw-r--r--src/bin/ngit/sub_commands/issue_list.rs8
-rw-r--r--src/bin/ngit/sub_commands/list.rs8
-rw-r--r--src/bin/ngit/sub_commands/send.rs52
5 files changed, 39 insertions, 39 deletions
diff --git a/src/bin/ngit/cli.rs b/src/bin/ngit/cli.rs
index 8cdbee1..8660b60 100644
--- a/src/bin/ngit/cli.rs
+++ b/src/bin/ngit/cli.rs
@@ -397,9 +397,9 @@ pub enum IssueCommands {
397 }, 397 },
398 /// create a new issue 398 /// create a new issue
399 Create { 399 Create {
400 /// Issue title 400 /// Issue subject/title
401 #[arg(long)] 401 #[arg(long, alias = "title")]
402 title: Option<String>, 402 subject: Option<String>,
403 /// Issue body / description 403 /// Issue body / description
404 #[arg(long)] 404 #[arg(long)]
405 body: Option<String>, 405 body: Option<String>,
diff --git a/src/bin/ngit/main.rs b/src/bin/ngit/main.rs
index 1dbf020..3f5e65c 100644
--- a/src/bin/ngit/main.rs
+++ b/src/bin/ngit/main.rs
@@ -179,11 +179,11 @@ async fn main() {
179 .await 179 .await
180 } 180 }
181 IssueCommands::Create { 181 IssueCommands::Create {
182 title, 182 subject,
183 body, 183 body,
184 labels, 184 labels,
185 } => { 185 } => {
186 sub_commands::issue_create::launch(title.clone(), body.clone(), labels.clone()) 186 sub_commands::issue_create::launch(subject.clone(), body.clone(), labels.clone())
187 .await 187 .await
188 } 188 }
189 IssueCommands::Close { id, reason, offline } => { 189 IssueCommands::Close { id, reason, offline } => {
diff --git a/src/bin/ngit/sub_commands/issue_list.rs b/src/bin/ngit/sub_commands/issue_list.rs
index 8c7a7fc..8f78d5e 100644
--- a/src/bin/ngit/sub_commands/issue_list.rs
+++ b/src/bin/ngit/sub_commands/issue_list.rs
@@ -336,7 +336,7 @@ fn show_issue_details(
336 serde_json::json!({ 336 serde_json::json!({
337 "id": issue.id.to_string(), 337 "id": issue.id.to_string(),
338 "status": status, 338 "status": status,
339 "title": title, 339 "subject": title,
340 "author": issue.pubkey.to_bech32().unwrap_or_default(), 340 "author": issue.pubkey.to_bech32().unwrap_or_default(),
341 "labels": labels, 341 "labels": labels,
342 "comment_count": comment_count, 342 "comment_count": comment_count,
@@ -347,7 +347,7 @@ fn show_issue_details(
347 serde_json::json!({ 347 serde_json::json!({
348 "id": issue.id.to_string(), 348 "id": issue.id.to_string(),
349 "status": status, 349 "status": status,
350 "title": title, 350 "subject": title,
351 "author": issue.pubkey.to_bech32().unwrap_or_default(), 351 "author": issue.pubkey.to_bech32().unwrap_or_default(),
352 "labels": labels, 352 "labels": labels,
353 "comment_count": comment_count, 353 "comment_count": comment_count,
@@ -358,7 +358,7 @@ fn show_issue_details(
358 return Ok(()); 358 return Ok(());
359 } 359 }
360 360
361 println!("Title: {title}"); 361 println!("Subject: {title}");
362 println!("Author: {}", issue.pubkey.to_bech32().unwrap_or_default()); 362 println!("Author: {}", issue.pubkey.to_bech32().unwrap_or_default());
363 println!("Status: {status}"); 363 println!("Status: {status}");
364 if !labels.is_empty() { 364 if !labels.is_empty() {
@@ -470,7 +470,7 @@ fn output_json(issues: &[IssueRow<'_>]) -> Result<()> {
470 serde_json::json!({ 470 serde_json::json!({
471 "id": issue.id.to_string(), 471 "id": issue.id.to_string(),
472 "status": status_kind_to_str(*status_kind), 472 "status": status_kind_to_str(*status_kind),
473 "title": get_issue_title(issue, subject_override.as_deref()), 473 "subject": get_issue_title(issue, subject_override.as_deref()),
474 "author": issue.pubkey.to_bech32().unwrap_or_default(), 474 "author": issue.pubkey.to_bech32().unwrap_or_default(),
475 "labels": labels, 475 "labels": labels,
476 "comment_count": comment_count, 476 "comment_count": comment_count,
diff --git a/src/bin/ngit/sub_commands/list.rs b/src/bin/ngit/sub_commands/list.rs
index ab4f0f7..df147bc 100644
--- a/src/bin/ngit/sub_commands/list.rs
+++ b/src/bin/ngit/sub_commands/list.rs
@@ -413,7 +413,7 @@ fn output_json(proposals: &[(&nostr::Event, Kind, Vec<String>, Option<String>)])
413 serde_json::json!({ 413 serde_json::json!({
414 "id": id, 414 "id": id,
415 "status": status, 415 "status": status,
416 "title": title, 416 "subject": title,
417 "author": author, 417 "author": author,
418 "branch": branch, 418 "branch": branch,
419 "labels": proposal_labels, 419 "labels": proposal_labels,
@@ -497,7 +497,7 @@ fn show_proposal_details(
497 serde_json::json!({ 497 serde_json::json!({
498 "id": proposal.id.to_string(), 498 "id": proposal.id.to_string(),
499 "status": status_kind_to_str(*status_kind), 499 "status": status_kind_to_str(*status_kind),
500 "title": display_title, 500 "subject": display_title,
501 "author": proposal.pubkey.to_bech32().unwrap_or_default(), 501 "author": proposal.pubkey.to_bech32().unwrap_or_default(),
502 "branch": cover_letter.get_branch_name_with_pr_prefix_and_shorthand_id()?, 502 "branch": cover_letter.get_branch_name_with_pr_prefix_and_shorthand_id()?,
503 "labels": proposal_labels, 503 "labels": proposal_labels,
@@ -509,7 +509,7 @@ fn show_proposal_details(
509 serde_json::json!({ 509 serde_json::json!({
510 "id": proposal.id.to_string(), 510 "id": proposal.id.to_string(),
511 "status": status_kind_to_str(*status_kind), 511 "status": status_kind_to_str(*status_kind),
512 "title": display_title, 512 "subject": display_title,
513 "author": proposal.pubkey.to_bech32().unwrap_or_default(), 513 "author": proposal.pubkey.to_bech32().unwrap_or_default(),
514 "branch": cover_letter.get_branch_name_with_pr_prefix_and_shorthand_id()?, 514 "branch": cover_letter.get_branch_name_with_pr_prefix_and_shorthand_id()?,
515 "labels": proposal_labels, 515 "labels": proposal_labels,
@@ -521,7 +521,7 @@ fn show_proposal_details(
521 return Ok(()); 521 return Ok(());
522 } 522 }
523 523
524 println!("Title: {display_title}"); 524 println!("Subject: {display_title}");
525 println!( 525 println!(
526 "Author: {}", 526 "Author: {}",
527 proposal.pubkey.to_bech32().unwrap_or_default() 527 proposal.pubkey.to_bech32().unwrap_or_default()
diff --git a/src/bin/ngit/sub_commands/send.rs b/src/bin/ngit/sub_commands/send.rs
index 86af2d3..e7671a2 100644
--- a/src/bin/ngit/sub_commands/send.rs
+++ b/src/bin/ngit/sub_commands/send.rs
@@ -38,9 +38,9 @@ pub struct SubCommandArgs {
38 /// don't prompt for a cover letter 38 /// don't prompt for a cover letter
39 #[arg(long, action)] 39 #[arg(long, action)]
40 pub(crate) no_cover_letter: bool, 40 pub(crate) no_cover_letter: bool,
41 /// optional cover letter title 41 /// optional cover letter subject/title
42 #[clap(long)] 42 #[clap(long, alias = "title")]
43 pub(crate) title: Option<String>, 43 pub(crate) subject: Option<String>,
44 #[clap(long)] 44 #[clap(long)]
45 /// optional cover letter description 45 /// optional cover letter description
46 pub(crate) description: Option<String>, 46 pub(crate) description: Option<String>,
@@ -73,23 +73,23 @@ fn validate_send_args(cli: &Cli, args: &SubCommandArgs) -> Result<()> {
73 return Ok(()); 73 return Ok(());
74 } 74 }
75 75
76 // Description requires title 76 // Description requires subject
77 if args.description.is_some() && args.title.is_none() { 77 if args.description.is_some() && args.subject.is_none() {
78 let message = "ngit send requires --title when --description is provided"; 78 let message = "ngit send requires --subject when --description is provided";
79 let details = vec![("--title <T>", "cover letter title")]; 79 let details = vec![("--subject <T>", "cover letter subject")];
80 let suggestions = vec![ 80 let suggestions = vec![
81 "ngit send HEAD~2 --title \"My Feature\" --description \"Details\"", 81 "ngit send HEAD~2 --subject \"My Feature\" --description \"Details\"",
82 "ngit send --interactive", 82 "ngit send --interactive",
83 ]; 83 ];
84 return Err(cli_error(message, &details, &suggestions)); 84 return Err(cli_error(message, &details, &suggestions));
85 } 85 }
86 86
87 // Title requires description 87 // Subject requires description
88 if args.title.is_some() && args.description.is_none() { 88 if args.subject.is_some() && args.description.is_none() {
89 let message = "ngit send requires --description when --title is provided"; 89 let message = "ngit send requires --description when --subject is provided";
90 let details = vec![("--description <D>", "cover letter description")]; 90 let details = vec![("--description <D>", "cover letter description")];
91 let suggestions = vec![ 91 let suggestions = vec![
92 "ngit send HEAD~2 --title \"My Feature\" --description \"Details\"", 92 "ngit send HEAD~2 --subject \"My Feature\" --description \"Details\"",
93 "ngit send --interactive", 93 "ngit send --interactive",
94 ]; 94 ];
95 return Err(cli_error(message, &details, &suggestions)); 95 return Err(cli_error(message, &details, &suggestions));
@@ -105,8 +105,8 @@ fn validate_send_args(cli: &Cli, args: &SubCommandArgs) -> Result<()> {
105 return Ok(()); 105 return Ok(());
106 } 106 }
107 107
108 // Both title and description provided - all good 108 // Both subject and description provided - all good
109 if args.title.is_some() && args.description.is_some() { 109 if args.subject.is_some() && args.description.is_some() {
110 return Ok(()); 110 return Ok(());
111 } 111 }
112 112
@@ -121,11 +121,11 @@ fn validate_send_args(cli: &Cli, args: &SubCommandArgs) -> Result<()> {
121 if args.since_or_range.is_empty() { 121 if args.since_or_range.is_empty() {
122 details.push(("<SINCE_OR_RANGE>", "commits to send (eg. HEAD~2)")); 122 details.push(("<SINCE_OR_RANGE>", "commits to send (eg. HEAD~2)"));
123 } 123 }
124 details.push(("--title <T> --description <D>", "cover letter details")); 124 details.push(("--subject <T> --description <D>", "cover letter details"));
125 details.push(("-d, --defaults", "use sensible defaults")); 125 details.push(("-d, --defaults", "use sensible defaults"));
126 details.push(("--interactive", "prompt for values")); 126 details.push(("--interactive", "prompt for values"));
127 let suggestions = vec![ 127 let suggestions = vec![
128 "ngit send HEAD~2 --title \"My Feature\" --description \"Details\"", 128 "ngit send HEAD~2 --subject \"My Feature\" --description \"Details\"",
129 "ngit send --defaults", 129 "ngit send --defaults",
130 "ngit send --interactive", 130 "ngit send --interactive",
131 ]; 131 ];
@@ -252,13 +252,13 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs, no_fetch: bool) -> Re
252 let cover_letter_title_description = if cli_args.interactive { 252 let cover_letter_title_description = if cli_args.interactive {
253 // Interactive flow: prompt for cover letter confirm, title, description 253 // Interactive flow: prompt for cover letter confirm, title, description
254 let title = if as_pr { 254 let title = if as_pr {
255 match &args.title { 255 match &args.subject {
256 Some(t) => Some(t.clone()), 256 Some(t) => Some(t.clone()),
257 None => { 257 None => {
258 if root_proposal.is_none() { 258 if root_proposal.is_none() {
259 Some( 259 Some(
260 Interactor::default() 260 Interactor::default()
261 .input(PromptInputParms::default().with_prompt("title"))? 261 .input(PromptInputParms::default().with_prompt("subject"))?
262 .clone(), 262 .clone(),
263 ) 263 )
264 } else { 264 } else {
@@ -269,7 +269,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs, no_fetch: bool) -> Re
269 } else if args.no_cover_letter { 269 } else if args.no_cover_letter {
270 None 270 None
271 } else { 271 } else {
272 match &args.title { 272 match &args.subject {
273 Some(t) => Some(t.clone()), 273 Some(t) => Some(t.clone()),
274 None => { 274 None => {
275 if Interactor::default().confirm( 275 if Interactor::default().confirm(
@@ -279,7 +279,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs, no_fetch: bool) -> Re
279 )? { 279 )? {
280 Some( 280 Some(
281 Interactor::default() 281 Interactor::default()
282 .input(PromptInputParms::default().with_prompt("title"))? 282 .input(PromptInputParms::default().with_prompt("subject"))?
283 .clone(), 283 .clone(),
284 ) 284 )
285 } else { 285 } else {
@@ -305,12 +305,12 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs, no_fetch: bool) -> Re
305 } 305 }
306 } else if as_pr { 306 } else if as_pr {
307 // PR always needs cover letter 307 // PR always needs cover letter
308 let title = match &args.title { 308 let title = match &args.subject {
309 Some(t) => t.clone(), 309 Some(t) => t.clone(),
310 None if cli_args.defaults => { 310 None if cli_args.defaults => {
311 git_repo.get_commit_message_summary(commits.first().context("no commits")?)? 311 git_repo.get_commit_message_summary(commits.first().context("no commits")?)?
312 } 312 }
313 None => bail!("PR requires --title and --description (or use --defaults)"), 313 None => bail!("PR requires --subject and --description (or use --defaults)"),
314 }; 314 };
315 let description = match &args.description { 315 let description = match &args.description {
316 Some(d) => d.clone(), 316 Some(d) => d.clone(),
@@ -324,15 +324,15 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs, no_fetch: bool) -> Re
324 .trim() 324 .trim()
325 .to_string() 325 .to_string()
326 } 326 }
327 None => bail!("PR requires --title and --description (or use --defaults)"), 327 None => bail!("PR requires --subject and --description (or use --defaults)"),
328 }; 328 };
329 Some((title, description)) 329 Some((title, description))
330 } else { 330 } else {
331 // Patch mode 331 // Patch mode
332 match (&args.title, &args.description) { 332 match (&args.subject, &args.description) {
333 (Some(t), Some(d)) => Some((t.clone(), d.clone())), 333 (Some(t), Some(d)) => Some((t.clone(), d.clone())),
334 (Some(_), None) => bail!("--title requires --description"), 334 (Some(_), None) => bail!("--subject requires --description"),
335 (None, Some(_)) => bail!("--description requires --title"), 335 (None, Some(_)) => bail!("--description requires --subject"),
336 (None, None) => None, // no cover letter 336 (None, None) => None, // no cover letter
337 } 337 }
338 }; 338 };