chroe: Check if the naddrs exists for issue new and patch send
Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
@@ -95,10 +95,10 @@ impl NewArgs {
|
|||||||
|
|
||||||
impl CommandRunner for NewArgs {
|
impl CommandRunner for NewArgs {
|
||||||
async fn run(self, options: CliOptions) -> N34Result<()> {
|
async fn run(self, options: CliOptions) -> N34Result<()> {
|
||||||
let naddrs = utils::naddrs_or_file(
|
let naddrs = utils::check_empty_naddrs(utils::naddrs_or_file(
|
||||||
self.naddrs.flat_naddrs(&options.config.sets)?,
|
self.naddrs.flat_naddrs(&options.config.sets)?,
|
||||||
&utils::nostr_address_path()?,
|
&utils::nostr_address_path()?,
|
||||||
)?;
|
)?)?;
|
||||||
let relays = options.relays.clone().flat_relays(&options.config.sets)?;
|
let relays = options.relays.clone().flat_relays(&options.config.sets)?;
|
||||||
let client = NostrClient::init(&options, &relays).await;
|
let client = NostrClient::init(&options, &relays).await;
|
||||||
let user_pubk = options.pubkey().await?;
|
let user_pubk = options.pubkey().await?;
|
||||||
|
|||||||
@@ -71,10 +71,11 @@ pub struct SendArgs {
|
|||||||
|
|
||||||
impl CommandRunner for SendArgs {
|
impl CommandRunner for SendArgs {
|
||||||
async fn run(self, options: CliOptions) -> N34Result<()> {
|
async fn run(self, options: CliOptions) -> N34Result<()> {
|
||||||
let naddrs = utils::naddrs_or_file(
|
let naddrs = utils::check_empty_naddrs(utils::naddrs_or_file(
|
||||||
self.naddrs.flat_naddrs(&options.config.sets)?,
|
self.naddrs.flat_naddrs(&options.config.sets)?,
|
||||||
&utils::nostr_address_path()?,
|
&utils::nostr_address_path()?,
|
||||||
)?;
|
)?)?;
|
||||||
|
|
||||||
let repo_coordinates = naddrs.clone().into_coordinates();
|
let repo_coordinates = naddrs.clone().into_coordinates();
|
||||||
let relays = options.relays.clone().flat_relays(&options.config.sets)?;
|
let relays = options.relays.clone().flat_relays(&options.config.sets)?;
|
||||||
let user_pubk = options.pubkey().await?;
|
let user_pubk = options.pubkey().await?;
|
||||||
|
|||||||
@@ -282,3 +282,12 @@ pub fn smart_wrap(text: &str, max_width: usize) -> String {
|
|||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join("\n")
|
.join("\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns an error if the given naddrs is empty otherwise returned it
|
||||||
|
pub fn check_empty_naddrs(naddrs: Vec<Nip19Coordinate>) -> N34Result<Vec<Nip19Coordinate>> {
|
||||||
|
if naddrs.is_empty() {
|
||||||
|
return Err(N34Error::EmptyNaddrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(naddrs)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user