feat: Read the nostr-address file in reply command
Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Add `--address-file` flag to `repo announce` command - by Awiteb
|
- Add `--address-file` flag to `repo announce` command - by Awiteb
|
||||||
- Read the `nostr-address` file in `repo view` command - by Awiteb
|
- Read the `nostr-address` file in `repo view` command - by Awiteb
|
||||||
- Read the `nostr-address` file in `issue new` command - by Awiteb
|
- Read the `nostr-address` file in `issue new` command - by Awiteb
|
||||||
|
- Read the `nostr-address` file in `reply` command - by Awiteb
|
||||||
|
|
||||||
## [0.1.0] - 2025-05-21
|
## [0.1.0] - 2025-05-21
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://gnu.org/licenses/gpl-3.0.html>.
|
// along with this program. If not, see <https://gnu.org/licenses/gpl-3.0.html>.
|
||||||
|
|
||||||
use std::str::FromStr;
|
use std::{fs, str::FromStr};
|
||||||
|
|
||||||
use clap::{ArgGroup, Args};
|
use clap::{ArgGroup, Args};
|
||||||
use nostr::{
|
use nostr::{
|
||||||
@@ -80,7 +80,10 @@ pub struct ReplyArgs {
|
|||||||
/// The issue, patch, or comment to reply to
|
/// The issue, patch, or comment to reply to
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
to: NostrEvent,
|
to: NostrEvent,
|
||||||
/// Repository address
|
/// Repository address in `naddr` format.
|
||||||
|
///
|
||||||
|
/// If not provided, `n34` will look for the `nostr-address` file and if not
|
||||||
|
/// found, will get it from the root event if found.
|
||||||
#[arg(short, long, value_parser = parsers::repo_naddr)]
|
#[arg(short, long, value_parser = parsers::repo_naddr)]
|
||||||
naddr: Option<Nip19Coordinate>,
|
naddr: Option<Nip19Coordinate>,
|
||||||
/// The comment (cannot be used with --editor)
|
/// The comment (cannot be used with --editor)
|
||||||
@@ -95,15 +98,13 @@ impl CommandRunner for ReplyArgs {
|
|||||||
async fn run(self, options: CliOptions) -> N34Result<()> {
|
async fn run(self, options: CliOptions) -> N34Result<()> {
|
||||||
let client = NostrClient::init(&options).await;
|
let client = NostrClient::init(&options).await;
|
||||||
let user_pubk = options.pubkey().await?;
|
let user_pubk = options.pubkey().await?;
|
||||||
let relays_list = client.user_relays_list(user_pubk).await?;
|
|
||||||
let mut write_relays =
|
|
||||||
utils::add_write_relays(options.relays.clone(), relays_list.as_ref());
|
|
||||||
client.add_relays(&options.relays).await;
|
client.add_relays(&options.relays).await;
|
||||||
client.add_relays(&self.to.relays).await;
|
client.add_relays(&self.to.relays).await;
|
||||||
|
|
||||||
if let Some(ref naddr) = self.naddr {
|
let relays_list = client.user_relays_list(user_pubk).await?;
|
||||||
client.add_relays(&naddr.relays).await;
|
let mut write_relays =
|
||||||
}
|
utils::add_write_relays(options.relays.clone(), relays_list.as_ref());
|
||||||
|
|
||||||
let reply_to = client
|
let reply_to = client
|
||||||
.fetch_event(Filter::new().id(self.to.event_id))
|
.fetch_event(Filter::new().id(self.to.event_id))
|
||||||
@@ -112,7 +113,13 @@ impl CommandRunner for ReplyArgs {
|
|||||||
let root = client.find_root(reply_to.clone()).await?;
|
let root = client.find_root(reply_to.clone()).await?;
|
||||||
|
|
||||||
|
|
||||||
|
let nostr_address_path = utils::nostr_address_path()?;
|
||||||
let repo_naddr = if let Some(naddr) = self.naddr {
|
let repo_naddr = if let Some(naddr) = self.naddr {
|
||||||
|
client.add_relays(&naddr.relays).await;
|
||||||
|
naddr.coordinate
|
||||||
|
} else if fs::exists(&nostr_address_path).is_ok() {
|
||||||
|
let naddr = utils::naddr_or_file(None, &nostr_address_path)?;
|
||||||
|
client.add_relays(&naddr.relays).await;
|
||||||
naddr.coordinate
|
naddr.coordinate
|
||||||
} else if let Some(ref root_event) = root {
|
} else if let Some(ref root_event) = root {
|
||||||
root_event
|
root_event
|
||||||
|
|||||||
Reference in New Issue
Block a user