diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-06-24 09:39:18 +0100 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-06-24 09:39:18 +0100 |
| commit | 173ab188b326fbe78cfba4ab455a74619f4556bb (patch) | |
| tree | 743a2413c241f7babd4efb336718c510eb743847 /src/sub_commands/login.rs | |
| parent | 681fdd7683363c62251ecd8dabcc1931a18f4840 (diff) | |
feat(login): store in git config and use cache
replace ngit yaml file config with:
* nsec / ncryptsec / npub in git config in nostr.* namespace
* sql database cache for metadata and relay events
allow different logins to be used for different git repositories by
storing login in local git config
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 | } |