Show help only for the error itself has to do with a command, argument, or option being invalid with dotnet nuget command#4211
Conversation
e00dfad to
9ce619b
Compare
| <data name="SignCommandNoCertificateException" xml:space="preserve"> | ||
| <value>No certificate was provided.</value> | ||
| </data> | ||
| <data name="TrustAuthorCommandDescription" xml:space="preserve"> |
There was a problem hiding this comment.
Have these strings been reviewed by a PM?
@chgill-MSFT
There was a problem hiding this comment.
Chris already approved it. Could you be able to review again?
There was a problem hiding this comment.
I don't really have any other concerns here.
Not signing off, but you already have the necessary 1 approval.
|
Erick - I had a quick look at the code, looks good so far. I think we need a follow-up issue to register subcommands in |
Sure, created follow up issue. dotnet/sdk#20249 |
src/NuGet.Clients/NuGet.PackageManagement.UI/NuGet.PackageManagement.UI.csproj
Outdated
Show resolved
Hide resolved
nkolev92
left a comment
There was a problem hiding this comment.
I'm happy to approve, I just want to make sure the user facing strings have been validated.
|
@chgill-MSFT |
chrisraygill
left a comment
There was a problem hiding this comment.
Overall LGTM, a couple minor questions and one word suggestion.
d09a8bb to
608c510
Compare
608c510 to
60efed9
Compare
I just addressed comments by Chris. |
|
This PR has been automatically marked as stale because it has no activity for 7 days. It will be closed if no further activity occurs within another 7 days of this comment. If it is closed, you may reopen it anytime when you're ready again, as long as you don't delete the branch. |
|
This PR has been automatically marked as stale because it has no activity for 7 days. It will be closed if no further activity occurs within another 7 days of this comment. If it is closed, you may reopen it anytime when you're ready again, as long as you don't delete the branch. |
3357cb3 to
df62f89
Compare
src/NuGet.Core/NuGet.CommandLine.XPlat/Commands/Signing/TrustedSignersCommand.cs
Show resolved
Hide resolved
src/NuGet.Core/NuGet.CommandLine.XPlat/Commands/Signing/TrustedSignersCommand.cs
Show resolved
Hide resolved
src/NuGet.Core/NuGet.CommandLine.XPlat/Commands/Signing/TrustedSignersCommand.cs
Show resolved
Hide resolved
src/NuGet.Core/NuGet.CommandLine.XPlat/Commands/Signing/TrustedSignersCommand.cs
Show resolved
Hide resolved
| CommandOption owners = sourceCommand.Option( | ||
| "--owners", | ||
| Strings.TrustCommandOwners, | ||
| CommandOptionType.MultipleValue); |
There was a problem hiding this comment.
As per doc, --owners option accepts list of values separated by semi-colon.
Copied from examples section in the doc, dotnet nuget trust source NuGetTrust https://api.nuget.org/v3/index.json --owners "Nuget;Microsoft"
I think CommandOptionType for this option should be SingleValue instead of MultipleValue. This comment applies to all the sub-commands which has owners as an option.
There was a problem hiding this comment.
Ok. I addressed your concerns. Please review again.
f8ba841 to
069b552
Compare
c5c7d7f to
7f0e36f
Compare
|
@kartheekp-ms |
Actually I need another approval to merge. Please review. |
|
|
||
| var runner = new TrustedSignersCommandRunner(trustedSignersProvider, sourceProvider); | ||
| Task<int> trustedSignTask = runner.ExecuteCommandAsync(trustedSignersArgs); | ||
| return await trustedSignTask; |
There was a problem hiding this comment.
| return await trustedSignTask; | |
| return trustedSignTask; |
There was a problem hiding this comment.
Even though this suggestion saves 1 machine state, but makes hard to track down aggregated exception(I couldn't find the link for ref, it brought up during last year learning day for async programming), maybe better to keep as it's since all other dotnet nuget implementation doing same.
src/NuGet.Core/NuGet.CommandLine.XPlat/Commands/Signing/TrustedSignersCommand.cs
Show resolved
Hide resolved
| Task<int> trustedSignTask = runner.ExecuteCommandAsync(trustedSignersArgs); | ||
| return await trustedSignTask; | ||
| } | ||
| catch (InvalidOperationException e) |
There was a problem hiding this comment.
More I think about it, the correct place for exception handling would have been within in the subcommand.OnExecute code block because the handlers are specific to the sub-commands. It is possible that I may be missing something here.
There was a problem hiding this comment.
I'll address this one next time I do NuGet/Home#10294
Bug
Fixes: NuGet/Home#10788
Regression? Last working version:
Description
Implemented sub commands so it show subcommand help instead of main
dotnet nuget trustcommand help for all cases.Previously, all options some not related to sub-command is displayed:

After, only relevant info for subcommand displayed.

Even main command help is changed:
Previously, doesn't show sub-commands.

After, sub commands are listed below:

Duplicate entry error(when try to add same trust certificate multiple times), doesn't display help info anymore:
Before:


After:
PR Checklist
PR has a meaningful title
PR has a linked issue.
Described changes
Tests
Documentation