feat: Read the nostr-address file in issue new command
Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Add `--force-id` flag to bypass case validation in `repo announce` - by Awiteb
|
- Add `--force-id` flag to bypass case validation in `repo announce` - by Awiteb
|
||||||
- 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
|
||||||
|
|
||||||
## [0.1.0] - 2025-05-21
|
## [0.1.0] - 2025-05-21
|
||||||
|
|
||||||
|
|||||||
@@ -39,9 +39,11 @@ use crate::{
|
|||||||
)
|
)
|
||||||
)]
|
)]
|
||||||
pub struct NewArgs {
|
pub struct NewArgs {
|
||||||
/// 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)]
|
#[arg(short, long, value_parser = parsers::repo_naddr)]
|
||||||
naddr: Nip19Coordinate,
|
naddr: Option<Nip19Coordinate>,
|
||||||
/// Markdown content for the issue. Cannot be used together with the
|
/// Markdown content for the issue. Cannot be used together with the
|
||||||
/// `--editor` flag.
|
/// `--editor` flag.
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
@@ -86,23 +88,22 @@ impl CommandRunner for NewArgs {
|
|||||||
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 naddr = utils::naddr_or_file(self.naddr.clone(), &utils::nostr_address_path()?)?;
|
||||||
|
|
||||||
|
client.add_relays(&options.relays).await;
|
||||||
|
client.add_relays(&naddr.relays).await;
|
||||||
|
|
||||||
let relays_list = client.user_relays_list(user_pubk).await?;
|
let relays_list = client.user_relays_list(user_pubk).await?;
|
||||||
let mut write_relays =
|
let mut write_relays =
|
||||||
utils::add_write_relays(options.relays.clone(), relays_list.as_ref());
|
utils::add_write_relays(options.relays.clone(), relays_list.as_ref());
|
||||||
client.add_relays(&options.relays).await;
|
write_relays.extend(client.fetch_repo(&naddr.coordinate).await?.relays);
|
||||||
client.add_relays(&self.naddr.relays).await;
|
|
||||||
write_relays.extend(client.fetch_repo(&self.naddr.coordinate).await?.relays);
|
|
||||||
|
|
||||||
let (subject, content) = self.issue_content()?;
|
let (subject, content) = self.issue_content()?;
|
||||||
let content_details = client.parse_content(&content).await;
|
let content_details = client.parse_content(&content).await;
|
||||||
write_relays.extend(content_details.write_relays.clone());
|
write_relays.extend(content_details.write_relays.clone());
|
||||||
|
|
||||||
let event = EventBuilder::new_git_issue(
|
let event =
|
||||||
self.naddr.coordinate.clone(),
|
EventBuilder::new_git_issue(naddr.coordinate.clone(), content, subject, self.label)?
|
||||||
content,
|
|
||||||
subject,
|
|
||||||
self.label,
|
|
||||||
)?
|
|
||||||
.tags(content_details.into_tags())
|
.tags(content_details.into_tags())
|
||||||
.pow(options.pow)
|
.pow(options.pow)
|
||||||
.build(user_pubk);
|
.build(user_pubk);
|
||||||
|
|||||||
Reference in New Issue
Block a user