diff options
Diffstat (limited to 'src/sub_commands')
| -rw-r--r-- | src/sub_commands/init.rs | 9 | ||||
| -rw-r--r-- | src/sub_commands/login.rs | 9 | ||||
| -rw-r--r-- | src/sub_commands/push.rs | 9 | ||||
| -rw-r--r-- | src/sub_commands/send.rs | 9 |
4 files changed, 29 insertions, 7 deletions
diff --git a/src/sub_commands/init.rs b/src/sub_commands/init.rs index edaca15..4d1bdfb 100644 --- a/src/sub_commands/init.rs +++ b/src/sub_commands/init.rs | |||
| @@ -59,7 +59,14 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 59 | #[cfg(test)] | 59 | #[cfg(test)] |
| 60 | let mut client = <MockConnect as std::default::Default>::default(); | 60 | let mut client = <MockConnect as std::default::Default>::default(); |
| 61 | 61 | ||
| 62 | let (keys, user_ref) = login::launch(&cli_args.nsec, &cli_args.password, Some(&client)).await?; | 62 | let (keys, user_ref) = login::launch( |
| 63 | &git_repo, | ||
| 64 | &cli_args.nsec, | ||
| 65 | &cli_args.password, | ||
| 66 | Some(&client), | ||
| 67 | false, | ||
| 68 | ) | ||
| 69 | .await?; | ||
| 63 | 70 | ||
| 64 | client.set_keys(&keys).await; | 71 | client.set_keys(&keys).await; |
| 65 | 72 | ||
diff --git a/src/sub_commands/login.rs b/src/sub_commands/login.rs index 43ce480..e71d431 100644 --- a/src/sub_commands/login.rs +++ b/src/sub_commands/login.rs | |||
| @@ -1,11 +1,11 @@ | |||
| 1 | use anyhow::Result; | 1 | use anyhow::{Context, Result}; |
| 2 | use clap; | 2 | use clap; |
| 3 | 3 | ||
| 4 | #[cfg(not(test))] | 4 | #[cfg(not(test))] |
| 5 | use crate::client::Client; | 5 | use crate::client::Client; |
| 6 | #[cfg(test)] | 6 | #[cfg(test)] |
| 7 | use crate::client::MockConnect; | 7 | use crate::client::MockConnect; |
| 8 | use crate::{client::Connect, login, Cli}; | 8 | use crate::{client::Connect, git::Repo, login, Cli}; |
| 9 | 9 | ||
| 10 | #[derive(clap::Args)] | 10 | #[derive(clap::Args)] |
| 11 | pub struct SubCommandArgs { | 11 | pub struct SubCommandArgs { |
| @@ -15,8 +15,9 @@ pub struct SubCommandArgs { | |||
| 15 | } | 15 | } |
| 16 | 16 | ||
| 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 | if command_args.offline { | 19 | if command_args.offline { |
| 19 | login::launch(&args.nsec, &args.password, None).await?; | 20 | login::launch(&git_repo, &args.nsec, &args.password, None, true).await?; |
| 20 | Ok(()) | 21 | Ok(()) |
| 21 | } else { | 22 | } else { |
| 22 | #[cfg(not(test))] | 23 | #[cfg(not(test))] |
| @@ -24,7 +25,7 @@ pub async fn launch(args: &Cli, command_args: &SubCommandArgs) -> Result<()> { | |||
| 24 | #[cfg(test)] | 25 | #[cfg(test)] |
| 25 | let client = <MockConnect as std::default::Default>::default(); | 26 | let client = <MockConnect as std::default::Default>::default(); |
| 26 | 27 | ||
| 27 | login::launch(&args.nsec, &args.password, Some(&client)).await?; | 28 | login::launch(&git_repo, &args.nsec, &args.password, Some(&client), true).await?; |
| 28 | client.disconnect().await?; | 29 | client.disconnect().await?; |
| 29 | Ok(()) | 30 | Ok(()) |
| 30 | } | 31 | } |
diff --git a/src/sub_commands/push.rs b/src/sub_commands/push.rs index fefe102..ade2ff8 100644 --- a/src/sub_commands/push.rs +++ b/src/sub_commands/push.rs | |||
| @@ -148,7 +148,14 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 148 | ahead.len() | 148 | ahead.len() |
| 149 | ); | 149 | ); |
| 150 | 150 | ||
| 151 | let (keys, user_ref) = login::launch(&cli_args.nsec, &cli_args.password, Some(&client)).await?; | 151 | let (keys, user_ref) = login::launch( |
| 152 | &git_repo, | ||
| 153 | &cli_args.nsec, | ||
| 154 | &cli_args.password, | ||
| 155 | Some(&client), | ||
| 156 | false, | ||
| 157 | ) | ||
| 158 | .await?; | ||
| 152 | 159 | ||
| 153 | client.set_keys(&keys).await; | 160 | client.set_keys(&keys).await; |
| 154 | 161 | ||
diff --git a/src/sub_commands/send.rs b/src/sub_commands/send.rs index c8d900c..8971d8b 100644 --- a/src/sub_commands/send.rs +++ b/src/sub_commands/send.rs | |||
| @@ -178,7 +178,14 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 178 | } else { | 178 | } else { |
| 179 | None | 179 | None |
| 180 | }; | 180 | }; |
| 181 | let (keys, user_ref) = login::launch(&cli_args.nsec, &cli_args.password, Some(&client)).await?; | 181 | let (keys, user_ref) = login::launch( |
| 182 | &git_repo, | ||
| 183 | &cli_args.nsec, | ||
| 184 | &cli_args.password, | ||
| 185 | Some(&client), | ||
| 186 | false, | ||
| 187 | ) | ||
| 188 | .await?; | ||
| 182 | 189 | ||
| 183 | client.set_keys(&keys).await; | 190 | client.set_keys(&keys).await; |
| 184 | 191 | ||