Skip to content

Commit 0fdb03a

Browse files
committed
github: consolidate helper options; add --all option
Consolidate all the UI helper options for the GitHub `prompt` view in to an `Options` class (rather than bloat the execution handler with more arguments). Also fix a bug whereby the GitHub host provider would attempt to invoke the UI helper with an `--all` option when all authentication modes are available, but no such option is available! This option was only available on the old WPF UI helper, and was never carried forward to the Avalonia UI.
1 parent 24356dc commit 0fdb03a

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

src/shared/GitHub.UI/Commands/CredentialsCommand.cs

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,40 @@ protected CredentialsCommand(ICommandContext context)
3535
new Option("--pat", "Enable personal access token authentication.")
3636
);
3737

38-
Handler = CommandHandler.Create<string, string, bool, bool, bool>(ExecuteAsync);
38+
AddOption(
39+
new Option("--all", "Enable all available authentication options.")
40+
);
41+
42+
Handler = CommandHandler.Create<CommandOptions>(ExecuteAsync);
43+
}
44+
45+
private class CommandOptions
46+
{
47+
public string UserName { get; set; }
48+
public string EnterpriseUrl { get; set; }
49+
public bool Basic { get; set; }
50+
public bool Browser { get; set; }
51+
public bool Pat { get; set; }
52+
public bool All { get; set; }
3953
}
4054

41-
private async Task<int> ExecuteAsync(string enterpriseUrl, string userName, bool basic, bool browser, bool pat)
55+
private async Task<int> ExecuteAsync(CommandOptions options)
4256
{
4357
var viewModel = new CredentialsViewModel(Context.Environment)
4458
{
45-
ShowBrowserLogin = browser,
46-
ShowTokenLogin = pat,
47-
ShowBasicLogin = basic,
59+
ShowBrowserLogin = options.All || options.Browser,
60+
ShowTokenLogin = options.All || options.Pat,
61+
ShowBasicLogin = options.All || options.Basic,
4862
};
4963

50-
if (!GitHubHostProvider.IsGitHubDotCom(enterpriseUrl))
64+
if (!GitHubHostProvider.IsGitHubDotCom(options.EnterpriseUrl))
5165
{
52-
viewModel.EnterpriseUrl = enterpriseUrl;
66+
viewModel.EnterpriseUrl = options.EnterpriseUrl;
5367
}
5468

55-
if (!string.IsNullOrWhiteSpace(userName))
69+
if (!string.IsNullOrWhiteSpace(options.UserName))
5670
{
57-
viewModel.UserName = userName;
71+
viewModel.UserName = options.UserName;
5872
}
5973

6074
await ShowAsync(viewModel, CancellationToken.None);

0 commit comments

Comments
 (0)