Skip to content

--help and --version moved to the top of the Options section #2589

Closed

Description

@KalleOlaviNiemitalo

Now that the --help and --version options are added by the RootCommand constructor in 2.0.0-beta5.25306.1, rather than by CommandLineBuilderExtensions, they tend to stay at the beginning of the Command.Options list when the application adds its own options. The --help output then lists them at the top of the Options section, rather than at the bottom which would be more traditional.

I suppose an application could fix that by using IList<T>.Insert to add its options in front of those two, or more easily by clearing the whole list, adding its options, and then adding new instances of HelpOption and VersionOption. The latter solution would also let the application easily set a custom action for the HelpOption, as requested in #2588

It would be nicer if those options were placed at the bottom of the table by default, without the application needing to move them explicitly. But I'm not sure how to implement that now without breaking compatibility or extensibility.

I considered posting this as a comment in #2576 but filed as a separate issue because there might be some kind of fix.

Activity

  1. KalleOlaviNiemitalo commented on Jun 24, 2025

    @KalleOlaviNiemitalo
    Author

    In GNU argp, this is part of the option grouping feature: --help and --version go to group number -1, which is displayed last.

  2. added
    bug
    on Jun 24, 2025
  3. added this to the Triage milestone on Jun 24, 2025
  4. ptr727 commented on Jun 24, 2025

    @ptr727

    In GNU argp, this is part of the option grouping feature: --help and --version go to group number -1, which is displayed last.

    Last would be great, but now they are rendered before global / recursive options, i.e. in the middle of help output.

  5. modified the milestones: Triage, 2.0.0-beta7 on Aug 6, 2025
  6. self-assigned this
    on Aug 6, 2025
  7. added a commit that references this issue on Aug 8, 2025
    93464c9
  8. added a commit that references this issue on Aug 8, 2025
    48d6bff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Area-Helpbug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions