diff options
Diffstat (limited to 'src/sub_commands')
| -rw-r--r-- | src/sub_commands/init.rs | 2 | ||||
| -rw-r--r-- | src/sub_commands/login.rs | 22 | ||||
| -rw-r--r-- | src/sub_commands/push.rs | 2 | ||||
| -rw-r--r-- | src/sub_commands/send.rs | 12 |
4 files changed, 31 insertions, 7 deletions
diff --git a/src/sub_commands/init.rs b/src/sub_commands/init.rs index 4afe83c..57785db 100644 --- a/src/sub_commands/init.rs +++ b/src/sub_commands/init.rs | |||
| @@ -61,6 +61,8 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 61 | 61 | ||
| 62 | let (signer, user_ref) = login::launch( | 62 | let (signer, user_ref) = login::launch( |
| 63 | &git_repo, | 63 | &git_repo, |
| 64 | &cli_args.bunker_uri, | ||
| 65 | &cli_args.bunker_app_key, | ||
| 64 | &cli_args.nsec, | 66 | &cli_args.nsec, |
| 65 | &cli_args.password, | 67 | &cli_args.password, |
| 66 | Some(&client), | 68 | Some(&client), |
diff --git a/src/sub_commands/login.rs b/src/sub_commands/login.rs index e71d431..6f49ba8 100644 --- a/src/sub_commands/login.rs +++ b/src/sub_commands/login.rs | |||
| @@ -17,7 +17,16 @@ pub struct SubCommandArgs { | |||
| 17 | pub async fn launch(args: &Cli, command_args: &SubCommandArgs) -> Result<()> { | 17 | pub async fn launch(args: &Cli, command_args: &SubCommandArgs) -> Result<()> { |
| 18 | let git_repo = Repo::discover().context("cannot find a git repository")?; | 18 | let git_repo = Repo::discover().context("cannot find a git repository")?; |
| 19 | if command_args.offline { | 19 | if command_args.offline { |
| 20 | login::launch(&git_repo, &args.nsec, &args.password, None, true).await?; | 20 | login::launch( |
| 21 | &git_repo, | ||
| 22 | &args.bunker_uri, | ||
| 23 | &args.bunker_app_key, | ||
| 24 | &args.nsec, | ||
| 25 | &args.password, | ||
| 26 | None, | ||
| 27 | true, | ||
| 28 | ) | ||
| 29 | .await?; | ||
| 21 | Ok(()) | 30 | Ok(()) |
| 22 | } else { | 31 | } else { |
| 23 | #[cfg(not(test))] | 32 | #[cfg(not(test))] |
| @@ -25,7 +34,16 @@ pub async fn launch(args: &Cli, command_args: &SubCommandArgs) -> Result<()> { | |||
| 25 | #[cfg(test)] | 34 | #[cfg(test)] |
| 26 | let client = <MockConnect as std::default::Default>::default(); | 35 | let client = <MockConnect as std::default::Default>::default(); |
| 27 | 36 | ||
| 28 | login::launch(&git_repo, &args.nsec, &args.password, Some(&client), true).await?; | 37 | login::launch( |
| 38 | &git_repo, | ||
| 39 | &args.bunker_uri, | ||
| 40 | &args.bunker_app_key, | ||
| 41 | &args.nsec, | ||
| 42 | &args.password, | ||
| 43 | Some(&client), | ||
| 44 | true, | ||
| 45 | ) | ||
| 46 | .await?; | ||
| 29 | client.disconnect().await?; | 47 | client.disconnect().await?; |
| 30 | Ok(()) | 48 | Ok(()) |
| 31 | } | 49 | } |
diff --git a/src/sub_commands/push.rs b/src/sub_commands/push.rs index 92c1c18..3c471c0 100644 --- a/src/sub_commands/push.rs +++ b/src/sub_commands/push.rs | |||
| @@ -150,6 +150,8 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 150 | 150 | ||
| 151 | let (signer, user_ref) = login::launch( | 151 | let (signer, user_ref) = login::launch( |
| 152 | &git_repo, | 152 | &git_repo, |
| 153 | &cli_args.bunker_uri, | ||
| 154 | &cli_args.bunker_app_key, | ||
| 153 | &cli_args.nsec, | 155 | &cli_args.nsec, |
| 154 | &cli_args.password, | 156 | &cli_args.password, |
| 155 | Some(&client), | 157 | Some(&client), |
diff --git a/src/sub_commands/send.rs b/src/sub_commands/send.rs index 1d20e90..7c8f2ee 100644 --- a/src/sub_commands/send.rs +++ b/src/sub_commands/send.rs | |||
| @@ -19,7 +19,7 @@ use crate::{ | |||
| 19 | cli_interactor::{ | 19 | cli_interactor::{ |
| 20 | Interactor, InteractorPrompt, PromptConfirmParms, PromptInputParms, PromptMultiChoiceParms, | 20 | Interactor, InteractorPrompt, PromptConfirmParms, PromptInputParms, PromptMultiChoiceParms, |
| 21 | }, | 21 | }, |
| 22 | client::Connect, | 22 | client::{sign_event, Connect}, |
| 23 | git::{Repo, RepoActions}, | 23 | git::{Repo, RepoActions}, |
| 24 | login, | 24 | login, |
| 25 | repo_ref::{self, RepoRef, REPO_REF_KIND}, | 25 | repo_ref::{self, RepoRef, REPO_REF_KIND}, |
| @@ -180,6 +180,8 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 180 | }; | 180 | }; |
| 181 | let (signer, user_ref) = login::launch( | 181 | let (signer, user_ref) = login::launch( |
| 182 | &git_repo, | 182 | &git_repo, |
| 183 | &cli_args.bunker_uri, | ||
| 184 | &cli_args.bunker_app_key, | ||
| 183 | &cli_args.nsec, | 185 | &cli_args.nsec, |
| 184 | &cli_args.password, | 186 | &cli_args.password, |
| 185 | Some(&client), | 187 | Some(&client), |
| @@ -593,7 +595,7 @@ pub async fn generate_cover_letter_and_patch_events( | |||
| 593 | let mut events = vec![]; | 595 | let mut events = vec![]; |
| 594 | 596 | ||
| 595 | if let Some((title, description)) = cover_letter_title_description { | 597 | if let Some((title, description)) = cover_letter_title_description { |
| 596 | events.push(signer.sign_event_builder(EventBuilder::new( | 598 | events.push(sign_event(EventBuilder::new( |
| 597 | nostr::event::Kind::Custom(PATCH_KIND), | 599 | nostr::event::Kind::Custom(PATCH_KIND), |
| 598 | format!( | 600 | format!( |
| 599 | "From {} Mon Sep 17 00:00:00 2001\nSubject: [PATCH 0/{}] {title}\n\n{description}", | 601 | "From {} Mon Sep 17 00:00:00 2001\nSubject: [PATCH 0/{}] {title}\n\n{description}", |
| @@ -656,7 +658,7 @@ pub async fn generate_cover_letter_and_patch_events( | |||
| 656 | .map(|pk| Tag::public_key(*pk)) | 658 | .map(|pk| Tag::public_key(*pk)) |
| 657 | .collect(), | 659 | .collect(), |
| 658 | ].concat(), | 660 | ].concat(), |
| 659 | )).await | 661 | ), signer).await |
| 660 | .context("failed to create cover-letter event")?); | 662 | .context("failed to create cover-letter event")?); |
| 661 | } | 663 | } |
| 662 | 664 | ||
| @@ -883,7 +885,7 @@ pub async fn generate_patch_event( | |||
| 883 | .context("failed to get parent commit")?; | 885 | .context("failed to get parent commit")?; |
| 884 | let relay_hint = repo_ref.relays.first().map(nostr::UncheckedUrl::from); | 886 | let relay_hint = repo_ref.relays.first().map(nostr::UncheckedUrl::from); |
| 885 | 887 | ||
| 886 | signer.sign_event_builder(EventBuilder::new( | 888 | sign_event(EventBuilder::new( |
| 887 | nostr::event::Kind::Custom(PATCH_KIND), | 889 | nostr::event::Kind::Custom(PATCH_KIND), |
| 888 | git_repo | 890 | git_repo |
| 889 | .make_patch_from_commit(commit,&series_count) | 891 | .make_patch_from_commit(commit,&series_count) |
| @@ -1000,7 +1002,7 @@ pub async fn generate_patch_event( | |||
| 1000 | ], | 1002 | ], |
| 1001 | ] | 1003 | ] |
| 1002 | .concat(), | 1004 | .concat(), |
| 1003 | )).await | 1005 | ), signer).await |
| 1004 | .context("failed to sign event") | 1006 | .context("failed to sign event") |
| 1005 | } | 1007 | } |
| 1006 | // TODO | 1008 | // TODO |