diff --git a/CHANGELOG.md b/CHANGELOG.md index 36b6062..b3c25a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Add `--force-id` flag to bypass case validation in `repo announce` - by Awiteb +- Add `--address-file` flag to `repo announce` command - by Awiteb +- Read the `nostr-address` file in `repo view` command - by Awiteb ## [0.1.0] - 2025-05-21 diff --git a/src/cli/repo/view.rs b/src/cli/repo/view.rs index f6b27e9..ffbfa7b 100644 --- a/src/cli/repo/view.rs +++ b/src/cli/repo/view.rs @@ -22,25 +22,26 @@ use nostr::nips::nip19::Nip19Coordinate; use crate::{ cli::{CliOptions, CommandRunner, parsers}, error::N34Result, - nostr_utils::NostrClient, + nostr_utils::{NostrClient, utils}, }; /// Arguments for the `repo view` command #[derive(Args, Debug)] pub struct ViewArgs { - /// Nostr repository address + /// Repository address in `naddr` format. + /// + /// If not provided, `n34` will look for a `nostr-address` file. #[arg(short, long, value_parser = parsers::repo_naddr)] - naddr: Nip19Coordinate, + naddr: Option, } impl CommandRunner for ViewArgs { async fn run(self, options: CliOptions) -> N34Result<()> { + let naddr = utils::naddr_or_file(self.naddr, &utils::nostr_address_path()?)?; let client = NostrClient::init(&options).await; - if !self.naddr.relays.is_empty() { - client.add_relays(&self.naddr.relays).await; - } + client.add_relays(&naddr.relays).await; - let repo = client.fetch_repo(&self.naddr.coordinate).await?; + let repo = client.fetch_repo(&naddr.coordinate).await?; let mut msg = format!("ID: {}", repo.id); if let Some(name) = repo.name {