diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-11-21 16:53:17 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-11-21 16:53:17 +0000 |
| commit | f79014235e85554e3661b3f2a02b8fa88bc192ff (patch) | |
| tree | fceec3ff2df212148a3420af7cef81a3f818463e /src/bin/ngit/cli.rs | |
| parent | 91b0eac4daf92b7b740267ef203a1a8ba591974b (diff) | |
feat(login): overhaul login experience
* simplify login menu, making it more accessable to newcomers and
easier to select remote signer options
* enable `ngit login` to work from anywhere (not just a git repo)
* assume fresh login details saved to global git config but fallback
to local repository
* maintain local repository login via `ngit login --local`
* maintain login via CLI arguments eg `ngit send --nsec nsec123`
* nudge users to remember nsec when pasting in ncryptsec for a
better UX, whilst maintaining the option to be prompted for
password everytime
* create placeholder menu items for help menu and create account
Diffstat (limited to 'src/bin/ngit/cli.rs')
| -rw-r--r-- | src/bin/ngit/cli.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/bin/ngit/cli.rs b/src/bin/ngit/cli.rs index d0f934e..b243f70 100644 --- a/src/bin/ngit/cli.rs +++ b/src/bin/ngit/cli.rs | |||
| @@ -1,4 +1,6 @@ | |||
| 1 | use anyhow::{bail, Result}; | ||
| 1 | use clap::{Parser, Subcommand}; | 2 | use clap::{Parser, Subcommand}; |
| 3 | use ngit::login::SignerInfo; | ||
| 2 | 4 | ||
| 3 | use crate::sub_commands; | 5 | use crate::sub_commands; |
| 4 | 6 | ||
| @@ -25,6 +27,30 @@ pub struct Cli { | |||
| 25 | pub disable_cli_spinners: bool, | 27 | pub disable_cli_spinners: bool, |
| 26 | } | 28 | } |
| 27 | 29 | ||
| 30 | pub fn extract_signer_cli_arguments(args: &Cli) -> Result<Option<SignerInfo>> { | ||
| 31 | if let Some(nsec) = &args.nsec { | ||
| 32 | Ok(Some(SignerInfo::Nsec { | ||
| 33 | nsec: nsec.to_string(), | ||
| 34 | password: None, | ||
| 35 | npub: None, | ||
| 36 | })) | ||
| 37 | } else if let Some(bunker_uri) = args.bunker_uri.clone() { | ||
| 38 | if let Some(bunker_app_key) = args.bunker_app_key.clone() { | ||
| 39 | Ok(Some(SignerInfo::Bunker { | ||
| 40 | bunker_uri, | ||
| 41 | bunker_app_key, | ||
| 42 | npub: None, | ||
| 43 | })) | ||
| 44 | } else { | ||
| 45 | bail!("cli argument bunker-app-key must be supplied when bunker-uri is") | ||
| 46 | } | ||
| 47 | } else if args.bunker_app_key.is_some() { | ||
| 48 | bail!("cli argument bunker-uri must be supplied when bunker-app-key is") | ||
| 49 | } else { | ||
| 50 | Ok(None) | ||
| 51 | } | ||
| 52 | } | ||
| 53 | |||
| 28 | #[derive(Subcommand)] | 54 | #[derive(Subcommand)] |
| 29 | pub enum Commands { | 55 | pub enum Commands { |
| 30 | /// update cache with latest updates from nostr | 56 | /// update cache with latest updates from nostr |