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

Updating to use the latest System.CommandLine #343

Merged
merged 1 commit into from
Apr 29, 2022

Conversation

Keboo
Copy link
Member

@Keboo Keboo commented Apr 29, 2022

I tried to keep the structure similar to what was there previously.

Some notable differences.

  1. Had to update to using the CommandLineBuilder directly because calling Command.Invoke with and option that matched the --version caused an error with a duplicate symbol.
  2. The default value on the help output for most of the items is now showing as [] where before it was [default: ]
  3. The two column rendering in the help builder required creating a HelpContext I believe this API could be improved in System.CommandLine to make this easier.

aliases: new string[] { "--file-directory", "-F" },
description: "The base path for files to parse.",
argumentType: typeof(string),
getDefaultValue: () => string.Empty,
arity: ArgumentArity.ExactlyOne
Copy link
Member

Choose a reason for hiding this comment

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

What, if anything, controls the arity allowed now and therefore errors if more than one --file-directory is specified?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is now defaulted based on the generic type of the option (which is forwarded to the option's argument).
It can be overridden by specifying a specific value for the Arity property, however it appeared that the options here were all following the defaults.

You can see the default Arity for different types here: https://github.com/dotnet/command-line-api/blob/main/src/System.CommandLine/ArgumentArity.cs#L144-L168

Copy link
Member

@tannergooding tannergooding left a comment

Choose a reason for hiding this comment

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

The changes LGTM. Thanks a lot for the contribution!

Just one question around how arity works now.

@tannergooding tannergooding merged commit 24d5a27 into dotnet:main Apr 29, 2022
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.

2 participants