Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

title argument passed to nested @OptionGroup has no effect #558

Open
2 tasks done
MaxDesiatov opened this issue Mar 1, 2023 · 1 comment
Open
2 tasks done

title argument passed to nested @OptionGroup has no effect #558

MaxDesiatov opened this issue Mar 1, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@MaxDesiatov
Copy link
Member

MaxDesiatov commented Mar 1, 2023

@OptionGroup behaves in an unexpected way with nested groups when title: argument value is specified.

ArgumentParser version: 1.2.2
Swift version:
swift-driver version: 1.62.15 Apple Swift version 5.7.2 (swiftlang-5.7.2.135.5 clang-1400.0.29.51)
Target: arm64-apple-macosx13.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

Create a type that has properties using @OptionGroup property wrapper with title: argument passed. Uses this type then as @OptionGroup itself. This top level may specify or not specify its own title: argument, this doesn't make a difference on the observed outcome.

Expected behavior

Nested @OptionGroups have their title: values displayed and options grouped by these titles in help output.

Actual behavior

Nested @OptionGroups don't have their title: values displayed and options grouped by these titles in help output. All of the options are displayed within the top-level group, title: values on nested groups have no effect whatsoever.

@natecook1000
Copy link
Member

Great spot, @MaxDesiatov — it would be great if these could preserve their titles when nested. What do you think the behavior should be if the "parent" option group also includes a title? That is, what should the help look like in this case?

struct A: ParsableArguments {
    @Flag var one = false
    @Flag var two = false
}

struct B: ParsableArguments {
    @Flag var three = false
    @Flag var four = false
}

struct Options: ParsableArguments {
    @OptionGroup(title: "Group A")
    var groupA: A

    @OptionGroup(title: "Group B")
    var groupB: B
}

struct Command: ParsableCommand {
    @OptionGroup(title: "All Options")
    var options: Options
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants