Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add why and config commands to dotnet nuget help #5931

Merged
merged 4 commits into from
Jul 26, 2024

Conversation

martinrrm
Copy link
Contributor

Bug

Fixes: NuGet/Home#13517

Description

Added missing commands to dotnet nuget help commands, since the migration of the commands is still a work in progress we need to add them to the old help option.

This PR only register so we can display their description but the functionality is implemented in System.Commandline.CliCommand

PR Checklist

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • Added tests
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.

@martinrrm martinrrm requested a review from a team as a code owner July 22, 2024 21:23
// Assert
var output = consoleOutput.ToString();

var commandPattern = @"^\s{2}(\w+)\s{2,}"; // Matches lines starting with two spaces, a word (command), followed by at least two spaces
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this behavior always same? I mean, will each line have 2 spaces + command + 2 spaces?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For now yes, I know this is not the best way to rely, when I finish the migration to the command I will make sure there is an easier way to know which commands are implemented.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there an epic where you are tracking the work for migration? If yes, I suggest adding a tracking issue so that we don't forget.

zivkan
zivkan previously approved these changes Jul 23, 2024

foreach (var command in HelpCommands)
{
Assert.Contains(command, matches);
Copy link
Member

Choose a reason for hiding this comment

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

I'm thinking about what kind of regressions this test will catch, and what it will miss.

It will catch someone removing an existing command from the help. For example, if one command is ported from the existing CLI parser to System.CommandLine and the person removes the comand registration from the dotnet nuget * code path, this test will fail, telling the developer not to do that.

This test will not catch the scenario where a brand new command is implemeneted and is special cased like config and why are, so they don't get registered through the dotnet nuget * code path. That's exactly the scenario for config and why commands that this PR is fixing.

Since commands don't need to implement an interface, or extend a base class, I don't have any ideas for how we could improve the test to catch the second scenario. I just wanted to raise awareness, in case someone else reviewing has an idea for an easy way to do it. My philosophy for bug fixes is that any tests added should have prevented the bug in the first place, had the test been in place before the bug was introduced. But this test unfortunately would not have, and I can't think of a nice way to do so. Maybe this is just a temporary thing until the System.CommandLine migration is complete.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed the comparison a little bit, I'll check that both have the same strings in the same order and the sizes are the same.

This could me improved later when we finish the migration because there is no nice way to compare it :(

zivkan
zivkan previously approved these changes Jul 24, 2024
@martinrrm martinrrm merged commit 5485ea6 into dev Jul 26, 2024
28 of 29 checks passed
@martinrrm martinrrm deleted the dev-martinrrm-missing-commands-dotnet-nuget-help branch July 26, 2024 18:19
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.

'why' and 'config' command does not show up in 'dotnet nuget --help' output
3 participants