diff options
Diffstat (limited to 'src/bin/ngit/sub_commands/create.rs')
| -rw-r--r-- | src/bin/ngit/sub_commands/create.rs | 30 |
1 files changed, 23 insertions, 7 deletions
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!"); |