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:
authorDanConwayDev <DanConwayDev@protonmail.com>2026-02-11 09:20:48 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2026-02-11 15:54:51 +0000
commit15bf0d0b6befae6c81631c0e5d0dc2947dd3318a (patch)
tree3d12d8b104c7a36ac8d2a7194da26fb432c95f23 /src/bin/ngit
parent459d33b6d7d3e5fdd55780670cd05d8141e670ac (diff)
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.
Diffstat (limited to 'src/bin/ngit')
-rw-r--r--src/bin/ngit/cli.rs2
-rw-r--r--src/bin/ngit/sub_commands/create.rs30
2 files changed, 24 insertions, 8 deletions
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.
53Currently the only settings not reachable through standard commands relate to default hardcoded relays: 53Currently the only settings not reachable through standard commands relate to default hardcoded relays:
54 54
55 - nostr.grasp-default-set - only used during `ngit init` 55 - nostr.grasp-default-set - only used during `ngit init`
56 - nostr.relay-default-set - must have at least 1 value, all events send to repo relays, user write and default relays 56 - nostr.relay-default-set - used for profile discovery and account bootstrapping
57 - nostr.relay-blaster-set - only used for repo announcement events 57 - nostr.relay-blaster-set - only used for repo announcement events
58 - nostr.relay-signer-fallback-set 58 - nostr.relay-signer-fallback-set
59 59
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 {
16 #[arg(long, required = true)] 16 #[arg(long, required = true)]
17 pub name: String, 17 pub name: String,
18 18
19 /// Relay URLs for the new account's relay list (can be specified multiple
20 /// times). Defaults to the relay-default-set if not provided.
21 #[arg(long = "relay", value_parser, num_args = 1)]
22 pub relays: Vec<String>,
23
19 /// Don't publish metadata to relays (offline mode) 24 /// Don't publish metadata to relays (offline mode)
20 #[arg(long)] 25 #[arg(long)]
21 pub offline: bool, 26 pub offline: bool,
@@ -28,20 +33,31 @@ pub struct SubCommandArgs {
28pub async fn launch(_cli: &Cli, args: &SubCommandArgs) -> Result<()> { 33pub async fn launch(_cli: &Cli, args: &SubCommandArgs) -> Result<()> {
29 let git_repo = Repo::discover().ok(); 34 let git_repo = Repo::discover().ok();
30 35
36 let params = Params::with_git_config_relay_defaults(&git_repo.as_ref());
37
38 let relay_urls = if args.relays.is_empty() {
39 params.relay_default_set.clone()
40 } else {
41 args.relays.clone()
42 };
43
31 let client = if args.offline { 44 let client = if args.offline {
32 None 45 None
33 } else { 46 } else {
34 Some(Client::new(Params::with_git_config_relay_defaults( 47 Some(Client::new(params))
35 &git_repo.as_ref(),
36 )))
37 }; 48 };
38 49
39 let publish = !args.offline; 50 let publish = !args.offline;
40 51
41 let (_signer, public_key, _signer_info, keys) = 52 let (_signer, public_key, _signer_info, keys) = signup_non_interactive(
42 signup_non_interactive(args.name.clone(), client.as_ref(), args.local, publish) 53 args.name.clone(),
43 .await 54 client.as_ref(),
44 .context("failed to create account")?; 55 args.local,
56 publish,
57 relay_urls,
58 )
59 .await
60 .context("failed to create account")?;
45 61
46 // Display the generated nsec prominently 62 // Display the generated nsec prominently
47 println!("\nāœ“ Account created successfully!"); 63 println!("\nāœ“ Account created successfully!");