upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/sub_commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/sub_commands')
-rw-r--r--src/sub_commands/prs/create.rs20
-rw-r--r--src/sub_commands/prs/mod.rs4
2 files changed, 21 insertions, 3 deletions
diff --git a/src/sub_commands/prs/create.rs b/src/sub_commands/prs/create.rs
index dd32c65..89ea652 100644
--- a/src/sub_commands/prs/create.rs
+++ b/src/sub_commands/prs/create.rs
@@ -3,6 +3,7 @@ use nostr::{prelude::sha1::Hash as Sha1Hash, EventBuilder, Marker, Tag, TagKind}
3 3
4use crate::{ 4use crate::{
5 cli_interactor::{Interactor, InteractorPrompt, PromptConfirmParms, PromptInputParms}, 5 cli_interactor::{Interactor, InteractorPrompt, PromptConfirmParms, PromptInputParms},
6 client::{Client, Connect, Params as ClientParams},
6 git::{Repo, RepoActions}, 7 git::{Repo, RepoActions},
7 login, Cli, 8 login, Cli,
8}; 9};
@@ -23,7 +24,7 @@ pub struct SubCommandArgs {
23 to_branch: Option<String>, 24 to_branch: Option<String>,
24} 25}
25 26
26pub fn launch( 27pub async fn launch(
27 cli_args: &Cli, 28 cli_args: &Cli,
28 _pr_args: &super::SubCommandArgs, 29 _pr_args: &super::SubCommandArgs,
29 args: &SubCommandArgs, 30 args: &SubCommandArgs,
@@ -81,6 +82,7 @@ pub fn launch(
81 let root_commit = git_repo 82 let root_commit = git_repo
82 .get_root_commit(to_branch.as_str()) 83 .get_root_commit(to_branch.as_str())
83 .context("failed to get root commit of the repository")?; 84 .context("failed to get root commit of the repository")?;
85
84 // create PR event 86 // create PR event
85 87
86 let keys = login::launch(&cli_args.nsec, &cli_args.password)?; 88 let keys = login::launch(&cli_args.nsec, &cli_args.password)?;
@@ -138,7 +140,23 @@ pub fn launch(
138 ); 140 );
139 } 141 }
140 142
143 let client = Client::new(ClientParams::default().with_keys(keys));
144
145 println!("connecting...");
146 client.connect().await?;
147 println!("connected...");
148
141 // TODO check if there is already a similarly named PR 149 // TODO check if there is already a similarly named PR
150 let _ = client
151 .send_event_to("ws://localhost:8080", pr_event)
152 .await?;
153 // TODO post each PR
154 // TODO report
155 println!("posted successfully to 4/5 of your relays and 0/4 of maintainers relays");
156 // should we have a relays in Repository event?
157 // yes
158 //
159
142 // TODO connect to relays and post 160 // TODO connect to relays and post
143 161
144 Ok(()) 162 Ok(())
diff --git a/src/sub_commands/prs/mod.rs b/src/sub_commands/prs/mod.rs
index c316e73..982e866 100644
--- a/src/sub_commands/prs/mod.rs
+++ b/src/sub_commands/prs/mod.rs
@@ -15,8 +15,8 @@ pub enum Commands {
15 Create(create::SubCommandArgs), 15 Create(create::SubCommandArgs),
16} 16}
17 17
18pub fn launch(cli_args: &Cli, pr_args: &SubCommandArgs) -> Result<()> { 18pub async fn launch(cli_args: &Cli, pr_args: &SubCommandArgs) -> Result<()> {
19 match &pr_args.prs_command { 19 match &pr_args.prs_command {
20 Commands::Create(args) => create::launch(cli_args, pr_args, args), 20 Commands::Create(args) => create::launch(cli_args, pr_args, args).await,
21 } 21 }
22} 22}