diff options
Diffstat (limited to 'src/sub_commands/login.rs')
| -rw-r--r-- | src/sub_commands/login.rs | 9 |
1 files changed, 5 insertions, 4 deletions
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 | } |