diff options
Diffstat (limited to 'src/bin')
| -rw-r--r-- | src/bin/ngit/cli.rs | 2 | ||||
| -rw-r--r-- | src/bin/ngit/sub_commands/create.rs | 30 |
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. | |||
| 53 | Currently the only settings not reachable through standard commands relate to default hardcoded relays: | 53 | Currently 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 { | |||
| 28 | pub async fn launch(_cli: &Cli, args: &SubCommandArgs) -> Result<()> { | 33 | pub 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!"); |