chore: A method to return the public key in CliOptions
Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user