diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-11-26 07:39:29 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-11-26 07:39:29 +0000 |
| commit | 1332c625b75fce616e06b415c99a068bc45c8210 (patch) | |
| tree | c58d49ec5ae9c8bb0ba87d084cd5e6dc4b6bce51 /src/bin/ngit | |
| parent | 0c5a3c001ccafd458a9b99b7513a9c8c172a54b2 (diff) | |
feat(login): improve err msg location
adding a prompt makes it easier for the eye to pick up the issue.
Diffstat (limited to 'src/bin/ngit')
| -rw-r--r-- | src/bin/ngit/sub_commands/login.rs | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/src/bin/ngit/sub_commands/login.rs b/src/bin/ngit/sub_commands/login.rs index 7bb0906..53da154 100644 --- a/src/bin/ngit/sub_commands/login.rs +++ b/src/bin/ngit/sub_commands/login.rs | |||
| @@ -69,20 +69,21 @@ async fn logout(git_repo: Option<&Repo>, local_only: bool) -> Result<(bool, bool | |||
| 69 | if let Ok((_, user_ref, source)) = | 69 | if let Ok((_, user_ref, source)) = |
| 70 | load_existing_login(&git_repo, &None, &None, &Some(source), None, true, false).await | 70 | load_existing_login(&git_repo, &None, &None, &Some(source), None, true, false).await |
| 71 | { | 71 | { |
| 72 | eprintln!( | ||
| 73 | "logged in {}as {}", | ||
| 74 | if source == SignerInfoSource::GitLocal { | ||
| 75 | "to local git repository " | ||
| 76 | } else { | ||
| 77 | "" | ||
| 78 | }, | ||
| 79 | user_ref.metadata.name | ||
| 80 | ); | ||
| 81 | match Interactor::default().choice( | 72 | match Interactor::default().choice( |
| 82 | PromptChoiceParms::default().with_default(0).with_choices( | 73 | PromptChoiceParms::default() |
| 83 | if source == SignerInfoSource::GitGlobal { | 74 | .with_default(0) |
| 75 | .with_prompt(format!( | ||
| 76 | "logged in {}as {}", | ||
| 77 | if source == SignerInfoSource::GitLocal { | ||
| 78 | "to local git repository " | ||
| 79 | } else { | ||
| 80 | "" | ||
| 81 | }, | ||
| 82 | user_ref.metadata.name | ||
| 83 | )) | ||
| 84 | .with_choices(if source == SignerInfoSource::GitGlobal { | ||
| 84 | vec![ | 85 | vec![ |
| 85 | format!("logout as \"{}\"", user_ref.metadata.name), | 86 | "logout".to_string(), |
| 86 | "remain logged in".to_string(), | 87 | "remain logged in".to_string(), |
| 87 | "login to local git repo only as another user".to_string(), | 88 | "login to local git repo only as another user".to_string(), |
| 88 | ] | 89 | ] |
| @@ -91,8 +92,7 @@ async fn logout(git_repo: Option<&Repo>, local_only: bool) -> Result<(bool, bool | |||
| 91 | format!("logout as \"{}\"", user_ref.metadata.name), | 92 | format!("logout as \"{}\"", user_ref.metadata.name), |
| 92 | "remain logged in".to_string(), | 93 | "remain logged in".to_string(), |
| 93 | ] | 94 | ] |
| 94 | }, | 95 | }), |
| 95 | ), | ||
| 96 | )? { | 96 | )? { |
| 97 | 0 => { | 97 | 0 => { |
| 98 | for item in [ | 98 | for item in [ |
| @@ -121,7 +121,9 @@ async fn logout(git_repo: Option<&Repo>, local_only: bool) -> Result<(bool, bool | |||
| 121 | format_items_as_list(&get_global_login_config_items_set()) | 121 | format_items_as_list(&get_global_login_config_items_set()) |
| 122 | ); | 122 | ); |
| 123 | match Interactor::default().choice( | 123 | match Interactor::default().choice( |
| 124 | PromptChoiceParms::default().with_default(0).with_choices( | 124 | PromptChoiceParms::default().with_default(0) |
| 125 | .with_prompt("failed to remove login details from global git config") | ||
| 126 | .with_choices( | ||
| 125 | vec![ | 127 | vec![ |
| 126 | "continue with global login to reveal what git config items to manually set".to_string(), | 128 | "continue with global login to reveal what git config items to manually set".to_string(), |
| 127 | "login to this local repository with a different account".to_string(), | 129 | "login to this local repository with a different account".to_string(), |