diff options
Diffstat (limited to 'src/bin/ngit/sub_commands/login.rs')
| -rw-r--r-- | src/bin/ngit/sub_commands/login.rs | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/src/bin/ngit/sub_commands/login.rs b/src/bin/ngit/sub_commands/login.rs index df7efa5..ae5efb1 100644 --- a/src/bin/ngit/sub_commands/login.rs +++ b/src/bin/ngit/sub_commands/login.rs | |||
| @@ -5,45 +5,31 @@ use crate::{ | |||
| 5 | cli::Cli, | 5 | cli::Cli, |
| 6 | client::{Client, Connect}, | 6 | client::{Client, Connect}, |
| 7 | git::Repo, | 7 | git::Repo, |
| 8 | login, | 8 | login::fresh::fresh_login_or_signup, |
| 9 | }; | 9 | }; |
| 10 | 10 | ||
| 11 | #[derive(clap::Args)] | 11 | #[derive(clap::Args)] |
| 12 | pub struct SubCommandArgs { | 12 | pub struct SubCommandArgs { |
| 13 | /// login to the local git repository only | ||
| 14 | #[arg(long, action)] | ||
| 15 | local: bool, | ||
| 16 | |||
| 13 | /// don't fetch user metadata and relay list from relays | 17 | /// don't fetch user metadata and relay list from relays |
| 14 | #[arg(long, action)] | 18 | #[arg(long, action)] |
| 15 | offline: bool, | 19 | offline: bool, |
| 16 | } | 20 | } |
| 17 | 21 | ||
| 18 | pub async fn launch(args: &Cli, command_args: &SubCommandArgs) -> Result<()> { | 22 | pub async fn launch(_args: &Cli, command_args: &SubCommandArgs) -> Result<()> { |
| 19 | let git_repo = Repo::discover().context("cannot find a git repository")?; | 23 | let git_repo = Repo::discover().context("cannot find a git repository")?; |
| 24 | // TODO show existing login on record, prompt to logout | ||
| 25 | // TODO use cli arguments to login | ||
| 20 | if command_args.offline { | 26 | if command_args.offline { |
| 21 | login::launch( | 27 | fresh_login_or_signup(&Some(&git_repo), None, command_args.local).await?; |
| 22 | &git_repo, | ||
| 23 | &args.bunker_uri, | ||
| 24 | &args.bunker_app_key, | ||
| 25 | &args.nsec, | ||
| 26 | &args.password, | ||
| 27 | None, | ||
| 28 | true, | ||
| 29 | false, | ||
| 30 | ) | ||
| 31 | .await?; | ||
| 32 | Ok(()) | 28 | Ok(()) |
| 33 | } else { | 29 | } else { |
| 34 | let client = Client::default(); | 30 | let client = Client::default(); |
| 31 | fresh_login_or_signup(&Some(&git_repo), Some(&client), command_args.local).await?; | ||
| 35 | 32 | ||
| 36 | login::launch( | ||
| 37 | &git_repo, | ||
| 38 | &args.bunker_uri, | ||
| 39 | &args.bunker_app_key, | ||
| 40 | &args.nsec, | ||
| 41 | &args.password, | ||
| 42 | Some(&client), | ||
| 43 | true, | ||
| 44 | false, | ||
| 45 | ) | ||
| 46 | .await?; | ||
| 47 | client.disconnect().await?; | 33 | client.disconnect().await?; |
| 48 | Ok(()) | 34 | Ok(()) |
| 49 | } | 35 | } |