Skip to content

Allow new HelpOption("--help") without aliases #2117

Closed

Description

@KalleOlaviNiemitalo

Now that #2102 in System.CommandLine 2.0.0-beta4.23172.1 made System.CommandLine.Help.HelpOption public, it would be handy if I could create an instance of HelpOption by using just new HelpOption("--help") rather than new HelpOption("--help", aliases: null). That could be implemented in any of the following ways:

  • new constructor: public HelpOption(string name)
  • optional parameter: public HelpOption(string name, string[]? aliases = null)
  • params: public HelpOption(string name, params string[] aliases). That would be consistent with the Option<T> constructor.

I don't like using new HelpOption("--help", null) with an unnamed null argument because its purpose would not be immediately obvious to people reading the code. new HelpOption("--help", Array.Empty<string>()) is quite clear too but more verbose than a named argument.

(System.CommandLine.Help.VersionOption is not public yet.)

Activity

  1. self-assigned this
    on Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions