Skip to content

Improve help text output by the default help subcommand #833

@rgoldberg

Description

@rgoldberg

The help text output by the default help subcommand doesn't seem proper to me:

  1. The USAGE section doesn't show -h, --help, or --version if they are autogenerated
  2. The USAGE section doesn't indicate that <subcommand> is optional, or that it can be followed by additional arguments
  3. The OPTIONS section lists --version before -h, --help, but I think they should be sorted alphabetically
  4. The SUBCOMMANDS section doesn't show help … Show help information., which I think should be inserted alphabetically in the subcommand list

ArgumentParser version:

main

Swift version: Paste the output of swift --version here.

swift-driver version: 1.127.14.1 Apple Swift version 6.2.1 (swiftlang-6.2.1.4.8 clang-1700.4.4.1)
Target: arm64-apple-macosx26.0

Checklist

  • If possible, I've reproduced the issue using the main branch of this package
  • I've searched for existing GitHub issues

Steps to Reproduce

Run the help subcommand of a command that has both a default help subcommand and that has CommandConfiguration.version set. They needn't exist together, but doing this shows both problems at once.

Expected behavior

Top-level help output:

OVERVIEW: Command

USAGE: cmd [(-h | --help) [<subcommand>] | --version | <subcommand> *…]

OPTIONS:
  -h, --help              Show help information.
  --version               Show the version.

SUBCOMMANDS:
  a                       A
  b                       B
  c                       C
  help                    Show help information.

Actual behavior

Top-level help output:

OVERVIEW: Command

USAGE: cmd <subcommand>

OPTIONS:
  --version               Show the version.
  -h, --help              Show help information.

SUBCOMMANDS:
  a                       A
  b                       B
  c                       C

Metadata

Metadata

Assignees

No one assigned

    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