feat: Read the nostr-address file in repo view command
Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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<Nip19Coordinate>,
|
||||
}
|
||||
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user