Skip to content

--help no longer displays the option argument if Option.HelpName is not set #2128

Description

@KalleOlaviNiemitalo

In System.CommandLine 2.0.0-beta4.22272.1 (commit 209b724), if I set up an option like this

            this.jsonDirectoryOption = new Option<DirectoryInfo>(
                name: "--json-directory",
                description: "Writes API JSON responses to the specified directory.");
            this.jsonDirectoryOption.ExistingOnly();
            this.Add(this.jsonDirectoryOption);

then --help generated a default description for the argument of the option:

  --json-directory    Writes API JSON responses to the specified directory.

In System.CommandLine 2.0.0-beta4.23165.2 (commit 4d1e6ac), if I similarly set up an option

            this.jsonDirectoryOption = new Option<DirectoryInfo>("--json-directory")
            {
                Description = "Writes API JSON responses to the specified directory.",
            };
            this.jsonDirectoryOption.AcceptExistingOnly();
            this.Options.Add(this.jsonDirectoryOption);

then --help does not show that the option requires an argument:

  --json-directory                    Writes API JSON responses to the specified directory.

I can correct the --help output by setting Option.HelpName in my application, but this is quite a surprising change and should at least be documented in the upcoming release notes.

Activity

KalleOlaviNiemitalo commented on Mar 30, 2023

@KalleOlaviNiemitalo
Author

I guess this change came from #2073, but I did not test before and after.

KalleOlaviNiemitalo commented on Mar 30, 2023

@KalleOlaviNiemitalo
Author

If you don't want to repeat the name of the option, then possibly this could use Type.Name of the argument, or just "value" localized. If the application developer does not want the option argument to be displayed at all, then they can set HelpName = "" or customize the first column of the help.

added this to the Triage milestone on Jun 24, 2025
self-assigned this
on Aug 8, 2025
modified the milestones: Triage, 2.0.0-beta7 on Aug 8, 2025
added a commit that references this issue on Aug 8, 2025
c928915
added a commit that references this issue on Aug 14, 2025
e292617
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions