From 4dea4785b47b3fbb3e98cdcee7ea8be59b46fadb Mon Sep 17 00:00:00 2001 From: Awiteb Date: Mon, 5 May 2025 19:51:10 +0000 Subject: [PATCH] chore: A method to return the public key in `CliOptions` Signed-off-by: Awiteb --- src/cli/mod.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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")