2

I'm using System.CommandLine to handle the command line parameters for an application.

I have a required parameter defined as:

var foo = new Option<string>("--foo", "...") { IsRequired = true };

For reasons, I need to change the name of this parameter. For backwards compatibility I want to keep the old name. That is, if the old name is used when running the application, I want it to still work.

I can achieve this by adding an alias:

var foo = new Option<string>(new[] { "--foo", "--bar" }, "...") { IsRequired = true };

However, when I do this the help output lists both aliases:

command line help output

I don't want that, as I want the old alias to only be there for backwards compatibility and to not be shown in this output.

I'm aware that there's an IsHidden = true flag on the Option, but that hides the whole parameter. Adding the old alias as a new second parameter instead also doesn't work as the parameter is required.

Is there any way to hide just the one alias?

adrianbanks
  • 81,306
  • 22
  • 176
  • 206

0 Answers0