Skip to content

Show help only for the error itself has to do with a command, argument, or option being invalid with dotnet nuget command#4211

Merged
erdembayar merged 19 commits intodevfrom
dev-eryondon-10788
Oct 5, 2021
Merged

Show help only for the error itself has to do with a command, argument, or option being invalid with dotnet nuget command#4211
erdembayar merged 19 commits intodevfrom
dev-eryondon-10788

Conversation

@erdembayar
Copy link
Copy Markdown
Contributor

@erdembayar erdembayar commented Aug 20, 2021

Bug

Fixes: NuGet/Home#10788

Regression? Last working version:

Description

Implemented sub commands so it show subcommand help instead of main dotnet nuget trust command help for all cases.

Previously, all options some not related to sub-command is displayed:
image

After, only relevant info for subcommand displayed.
image

Even main command help is changed:

Previously, doesn't show sub-commands.
image

After, sub commands are listed below:
image

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

Before:
image
After:
image

PR Checklist

  • PR has a meaningful title

  • PR has a linked issue.

  • Described changes

  • Tests

    • Automated tests added
    • OR
    • Test exception
    • OR
    • N/A
  • Documentation

    • Documentation PR or issue filled
    • OR
    • N/A

@erdembayar erdembayar requested a review from a team as a code owner August 20, 2021 01:10
@erdembayar erdembayar marked this pull request as draft August 20, 2021 01:10
@erdembayar erdembayar marked this pull request as ready for review August 20, 2021 01:27
<data name="SignCommandNoCertificateException" xml:space="preserve">
<value>No certificate was provided.</value>
</data>
<data name="TrustAuthorCommandDescription" xml:space="preserve">
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have these strings been reviewed by a PM?

@chgill-MSFT

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chris already approved it. Could you be able to review again?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really have any other concerns here.
Not signing off, but you already have the necessary 1 approval.

@kartheekp-ms
Copy link
Copy Markdown
Contributor

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 dotnet/sdk repo also. dotnet/sdk#18061 (comment)

@erdembayar
Copy link
Copy Markdown
Contributor Author

erdembayar commented Aug 27, 2021

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 dotnet/sdk repo also. dotnet/sdk#18061 (comment)

Sure, created follow up issue. dotnet/sdk#20249

Copy link
Copy Markdown
Member

@nkolev92 nkolev92 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to approve, I just want to make sure the user facing strings have been validated.

@erdembayar
Copy link
Copy Markdown
Contributor Author

@chgill-MSFT
Please validate newly added strings here.

Copy link
Copy Markdown

@chrisraygill chrisraygill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM, a couple minor questions and one word suggestion.

@erdembayar
Copy link
Copy Markdown
Contributor Author

I'm happy to approve, I just want to make sure the user facing strings have been validated.

I just addressed comments by Chris.

@erdembayar erdembayar requested a review from nkolev92 September 2, 2021 16:33
@ghost ghost added the Status:No recent activity PRs that have not had any recent activity and will be closed if the label is not removed label Sep 15, 2021
@ghost
Copy link
Copy Markdown

ghost commented Sep 15, 2021

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.

@ghost ghost removed the Status:No recent activity PRs that have not had any recent activity and will be closed if the label is not removed label Sep 21, 2021
@ghost ghost added the Status:No recent activity PRs that have not had any recent activity and will be closed if the label is not removed label Sep 28, 2021
@ghost
Copy link
Copy Markdown

ghost commented Sep 28, 2021

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.

@erdembayar erdembayar marked this pull request as draft September 29, 2021 17:56
@ghost ghost removed the Status:No recent activity PRs that have not had any recent activity and will be closed if the label is not removed label Sep 29, 2021
@erdembayar erdembayar marked this pull request as ready for review October 1, 2021 16:59
CommandOption owners = sourceCommand.Option(
"--owners",
Strings.TrustCommandOwners,
CommandOptionType.MultipleValue);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

@erdembayar erdembayar Oct 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I addressed your concerns. Please review again.

@erdembayar
Copy link
Copy Markdown
Contributor Author

@kartheekp-ms
If you don't have any other comment then I'll merge today evening. Nikolche already tacitly approved.

@erdembayar
Copy link
Copy Markdown
Contributor Author

@kartheekp-ms If you don't have any other comment then I'll merge today evening. Nikolche already tacitly approved.

Actually I need another approval to merge. Please review.


var runner = new TrustedSignersCommandRunner(trustedSignersProvider, sourceProvider);
Task<int> trustedSignTask = runner.ExecuteCommandAsync(trustedSignersArgs);
return await trustedSignTask;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return await trustedSignTask;
return trustedSignTask;

Copy link
Copy Markdown
Contributor Author

@erdembayar erdembayar Oct 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Task<int> trustedSignTask = runner.ExecuteCommandAsync(trustedSignersArgs);
return await trustedSignTask;
}
catch (InvalidOperationException e)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll address this one next time I do NuGet/Home#10294

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show subcommand help instead of main dotnet nuget trust command help for all cases

4 participants