refactor: Store the config in CliOptions instead of its path

Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
Awiteb
2025-06-07 18:57:53 +00:00
parent 30b3056d39
commit a6a61aedf1
15 changed files with 84 additions and 73 deletions

View File

@@ -21,7 +21,7 @@ use futures::future;
use nostr::{event::EventBuilder, key::PublicKey, types::Url};
use crate::{
cli::{CliConfig, CliOptions, CommandRunner, NOSTR_ADDRESS_FILE, types::RelayOrSetVecExt},
cli::{CliOptions, CommandRunner, NOSTR_ADDRESS_FILE, types::RelayOrSetVecExt},
error::N34Result,
nostr_utils::{NostrClient, traits::NewGitRepositoryAnnouncement, utils},
};
@@ -81,8 +81,7 @@ impl CommandRunner for AnnounceArgs {
async fn run(mut self, options: CliOptions) -> N34Result<()> {
options.ensure_relays()?;
let config = CliConfig::load_toml(&options.config_path)?;
let relays = options.relays.clone().flat_relays(&config.sets)?;
let relays = options.relays.clone().flat_relays(&options.config.sets)?;
let client = NostrClient::init(&options, &relays).await;
let user_pubk = options.pubkey().await?;
let relays_list = client.user_relays_list(user_pubk).await?;

View File

@@ -20,7 +20,6 @@ use clap::Args;
use crate::{
cli::{
CliConfig,
CliOptions,
CommandRunner,
types::{NaddrOrSet, OptionNaddrOrSetVecExt, RelayOrSetVecExt},
@@ -44,12 +43,11 @@ impl CommandRunner for ViewArgs {
async fn run(self, options: CliOptions) -> N34Result<()> {
// FIXME: The signer is not required here
let config = CliConfig::load_toml(&options.config_path)?;
let naddrs = utils::naddrs_or_file(
self.naddrs.flat_naddrs(&config.sets)?,
self.naddrs.flat_naddrs(&options.config.sets)?,
&utils::nostr_address_path()?,
)?;
let relays = options.relays.clone().flat_relays(&config.sets)?;
let relays = options.relays.clone().flat_relays(&options.config.sets)?;
let client = NostrClient::init(&options, &relays).await;
client.add_relays(&naddrs.extract_relays()).await;