From 6bfd8b0ddec7f8f4c24a97d357de9acd615b0b17 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Mon, 22 Apr 2024 09:29:18 +0100 Subject: feat(send): print link to proposal root after a new root proposal has been sent link directly to gitworkshop.dev as well as njump.me until gitworkshop is added to njump --- src/sub_commands/send.rs | 28 ++++++++++++++++++++++++++-- tests/send.rs | 12 ++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/sub_commands/send.rs b/src/sub_commands/send.rs index d9caf9b..78d00b2 100644 --- a/src/sub_commands/send.rs +++ b/src/sub_commands/send.rs @@ -6,7 +6,7 @@ use futures::future::join_all; use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; use nostr::{ nips::{nip01::Coordinate, nip19::Nip19}, - EventBuilder, FromBech32, Marker, Tag, TagKind, UncheckedUrl, + EventBuilder, FromBech32, Marker, Tag, TagKind, ToBech32, UncheckedUrl, }; use nostr_sdk::hashes::sha1::Hash as Sha1Hash; @@ -220,12 +220,36 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { send_events( &client, - events, + events.clone(), user_ref.relays.write(), repo_ref.relays.clone(), !cli_args.disable_cli_spinners, ) .await?; + + if args.in_reply_to.is_none() { + if let Some(event) = events.first() { + // TODO: add gitworkshop.dev to njump and remove direct gitworkshop link + println!( + "{}", + dim.apply_to(format!( + "view in gitworkshop.dev: https://gitworkshop.dev/repo/{}/proposal/{}", + repo_ref.identifier, + event.id(), + )) + ); + println!( + "{}", + dim.apply_to(format!( + "view in another client: https://njump.me/{}", + event + .id() + .to_bech32() + .context("cannot produce nevent from event id")? + )) + ); + } + } // TODO check if there is already a similarly named Ok(()) } diff --git a/tests/send.rs b/tests/send.rs index 4af2347..a38546a 100644 --- a/tests/send.rs +++ b/tests/send.rs @@ -147,6 +147,14 @@ fn expect_msgs_first(p: &mut CliTester, include_cover_letter: bool) -> Result<() Ok(()) } +fn expect_msgs_after(p: &mut CliTester) -> Result<()> { + p.expect_after_whitespace("view in gitworkshop.dev: https://gitworkshop.dev/repo")?; + p.expect_eventually("\r\n")?; + p.expect("view in another client: https://njump.me/")?; + p.expect_eventually("\r\n")?; + Ok(()) +} + async fn prep_run_create_proposal( include_cover_letter: bool, ) -> Result<( @@ -715,6 +723,7 @@ mod when_cover_letter_details_specified_with_range_of_head_2_sends_cover_letter_ ], 3, )?; + expect_msgs_after(&mut p)?; p.expect_end_with_whitespace()?; for p in [51, 52, 53, 55, 56] { relay::shutdown_relay(8000 + p)?; @@ -880,6 +889,7 @@ mod when_cover_letter_details_specified_with_range_of_head_2_sends_cover_letter_ ], 3, )?; + expect_msgs_after(&mut p)?; p.expect_end_with_whitespace()?; for p in [51, 52, 53, 55, 56] { relay::shutdown_relay(8000 + p)?; @@ -963,6 +973,7 @@ mod when_no_cover_letter_flag_set_with_range_of_head_2_sends_2_patches_without_c ], 2, )?; + expect_msgs_after(&mut p)?; p.expect_end_with_whitespace()?; for p in [51, 52, 53, 55, 56] { relay::shutdown_relay(8000 + p)?; @@ -1241,6 +1252,7 @@ mod when_range_ommited_prompts_for_selection_defaulting_ahead_of_main { ], 2, )?; + expect_msgs_after(&mut p)?; p.expect_end_with_whitespace()?; for p in [51, 52, 53, 55, 56] { relay::shutdown_relay(8000 + p)?; -- cgit v1.2.3