Skip to content

Mutually exclusive EnumerableFlag & RawRepresentable flags aren't documented as such in command help, possibly elsewhere #831

@rgoldberg

Description

@rgoldberg

Mutually exclusive EnumerableFlag & RawRepresentable flags aren't documented as such in command help.

They're just listed as independent flags.

Maybe they're also listed as independent elsewhere, e.g., generated man page, markdown, etc.

Maybe other types of mutually exclusive flags, options, arguments, whatever also suffer from this problem.

Also, the default flag is output in an overly verbose, confusing way:

  --a                     1 (default: --a)

Which probably should be:

  --a                     1 (default)

ArgumentParser version:

main

Swift version:

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

internal import ArgumentParser

struct C: ParsableCommand {
	static let configuration = CommandConfiguration(
		abstract: "C"
	)

	@Flag(help: "group text")
	private var e = E.a

	func run() {
		print(e)
	}
}

private enum E: String, EnumerableFlag {
	case a
	case b
	case c

	static func help(for e: Self) -> ArgumentHelp? {
		switch e {
		case .a:
			"1"
		case .b:
			"2"
		case .c:
			"3"
		}
	}
}

Expected behavior

$ c help
OVERVIEW: C

USAGE: cmd c [--a | --b | --c]

OPTIONS:
  --a                     1 (default)
  --b                     2
  --c                     3
  -h, --help              Show help information.

Or, maybe segment the mutually exclusive options together (output could be different):

$ c help
OVERVIEW: C

USAGE: cmd c [--a | --b | --c]

OPTIONS:
group text (mutually exclusive):
  --a                     1 (default)
  --b                     2
  --c                     3

OTHER OPTIONS:
  -h, --help              Show help information.

Actual behavior

$ c help
OVERVIEW: C

USAGE: cmd c [--a] [--b] [--c]

OPTIONS:
  --a                     1 (default: --a)
  --b                     2
  --c                     3

  -h, --help              Show help information.

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