Skip to content

Help of a subcommand prints also options from the main command #260

@tfonfara

Description

@tfonfara

--help flag of a subcommand or also help <subcommand> does also print options from the main command

ArgumentParser version: main
Swift version: 5.3.2

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

  1. Checkout main branch
  2. Add any @Option or @Flag to the Math struct
  3. Build the project with swift build
  4. Run math add --help

Sample:

struct Math: ParsableCommand {

    static var configuration = CommandConfiguration(
        ...
    )

    @Option(help: "Test option.")
    var test: String?

}

Expected behavior

Help of the subcommand only should be printed, options of the main command should not be printed

Sample:

OVERVIEW: Print the sum of the values.

USAGE: math add [--hex-output] [<values> ...]

ARGUMENTS:
  <values>                A group of integers to operate on. 

OPTIONS:
  -x, --hex-output        Use hexadecimal notation for the result. 
  --version               Show the version.
  -h, --help              Show help information.

Actual behavior

  • Overview, usage, arguments of the subcommand are being printed ✅
  • Options of the subcommand are being printed ✅
  • Options of the main command are being printed ❌

Sample:

OVERVIEW: Print the sum of the values.

USAGE: math add [--hex-output] [<values> ...]

ARGUMENTS:
  <values>                A group of integers to operate on. 

OPTIONS:
  --test <test>           Test option. 
  -x, --hex-output        Use hexadecimal notation for the result. 
  --version               Show the version.
  -h, --help              Show help information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions