diff --git a/src/cli/mod.rs b/src/cli/mod.rs index 0f9a257..5304f80 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -25,7 +25,8 @@ use std::fmt; use clap::{ArgGroup, Args, Parser}; use clap_verbosity_flag::Verbosity; -use nostr::{RelayUrl, SecretKey}; +use nostr::key::Keys; +use nostr::{PublicKey, RelayUrl, SecretKey}; pub use self::repo::RepoSubcommands; pub use self::traits::CommandRunner; @@ -112,6 +113,16 @@ impl CommandRunner for Commands { } } +impl CliOptions { + /// Gets the public key of the user. + pub async fn pubkey(&self) -> PublicKey { + if let Some(sk) = &self.secret_key { + return Keys::new(sk.clone()).public_key(); + } + unreachable!("There is no other method until now") + } +} + impl fmt::Debug for CliOptions { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("CliOptions")