upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/bin/ngit/cli.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/ngit/cli.rs')
-rw-r--r--src/bin/ngit/cli.rs26
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 @@
1use anyhow::{bail, Result};
1use clap::{Parser, Subcommand}; 2use clap::{Parser, Subcommand};
3use ngit::login::SignerInfo;
2 4
3use crate::sub_commands; 5use 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
30pub 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)]
29pub enum Commands { 55pub enum Commands {
30 /// update cache with latest updates from nostr 56 /// update cache with latest updates from nostr