From 15bf0d0b6befae6c81631c0e5d0dc2947dd3318a Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 11 Feb 2026 09:20:48 +0000 Subject: feat: use fallback relays for bootstrapping only - Add --relay flag to 'ngit account create' allowing users to specify relay URLs (repeatable). Defaults to relay-default-set when not provided. - Remove fallback relays from fetch when repo context exists (repo coordinate provided). Only use them for bootstrapping (profile discovery with no repo context). - Remove fallback relays from publish when repo or user relays exist. Only use them when neither is available (e.g. new account signup). - Update --customize help text to reflect new relay-default-set behavior. --- src/bin/ngit/cli.rs | 2 +- src/bin/ngit/sub_commands/create.rs | 30 +++++++++++++++++++++++------- 2 files changed, 24 insertions(+), 8 deletions(-) (limited to 'src/bin') diff --git a/src/bin/ngit/cli.rs b/src/bin/ngit/cli.rs index d2246d7..47f4b27 100644 --- a/src/bin/ngit/cli.rs +++ b/src/bin/ngit/cli.rs @@ -53,7 +53,7 @@ ngit settings are managed through the git config. Currently the only settings not reachable through standard commands relate to default hardcoded relays: - nostr.grasp-default-set - only used during `ngit init` - - nostr.relay-default-set - must have at least 1 value, all events send to repo relays, user write and default relays + - nostr.relay-default-set - used for profile discovery and account bootstrapping - nostr.relay-blaster-set - only used for repo announcement events - nostr.relay-signer-fallback-set diff --git a/src/bin/ngit/sub_commands/create.rs b/src/bin/ngit/sub_commands/create.rs index e0d89b5..1c2b8db 100644 --- a/src/bin/ngit/sub_commands/create.rs +++ b/src/bin/ngit/sub_commands/create.rs @@ -16,6 +16,11 @@ pub struct SubCommandArgs { #[arg(long, required = true)] pub name: String, + /// Relay URLs for the new account's relay list (can be specified multiple + /// times). Defaults to the relay-default-set if not provided. + #[arg(long = "relay", value_parser, num_args = 1)] + pub relays: Vec, + /// Don't publish metadata to relays (offline mode) #[arg(long)] pub offline: bool, @@ -28,20 +33,31 @@ pub struct SubCommandArgs { pub async fn launch(_cli: &Cli, args: &SubCommandArgs) -> Result<()> { let git_repo = Repo::discover().ok(); + let params = Params::with_git_config_relay_defaults(&git_repo.as_ref()); + + let relay_urls = if args.relays.is_empty() { + params.relay_default_set.clone() + } else { + args.relays.clone() + }; + let client = if args.offline { None } else { - Some(Client::new(Params::with_git_config_relay_defaults( - &git_repo.as_ref(), - ))) + Some(Client::new(params)) }; let publish = !args.offline; - let (_signer, public_key, _signer_info, keys) = - signup_non_interactive(args.name.clone(), client.as_ref(), args.local, publish) - .await - .context("failed to create account")?; + let (_signer, public_key, _signer_info, keys) = signup_non_interactive( + args.name.clone(), + client.as_ref(), + args.local, + publish, + relay_urls, + ) + .await + .context("failed to create account")?; // Display the generated nsec prominently println!("\n✓ Account created successfully!"); -- cgit v1.2.3