Skip to content

Conversation

natecook1000
Copy link
Member

The usage string feature that only shows positional args and required options/flags was incorrectly allowing through flags with type Bool?. For example, --enable-foo was incorrectly visible in the usage string for this type:

struct Example: ParsableCommand { // so many options // too many options @Flag(inversion: .prefixedEnableDisable) var foo: Bool? }

Checklist

  • I've added at least one test that validates that my change is working, if appropriate
  • I've followed the code style of the rest of the project
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary
The usage string feature that only shows positional args and required options/flags was incorrectly allowing through flags with type `Bool?`.
@natecook1000
Copy link
Member Author

@swift-ci Please test

help: ArgumentHelp?) -> ArgumentSet
{
// The flag is required if initialValue is `nil`, otherwise it's optional
let helpOptions: ArgumentDefinition.Help.Options = initialValue != nil ? .isOptional : []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update comment above?

Copy link
Member

@tomerd tomerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good. one nit about redundant comment

tomerd added a commit to tomerd/swift-package-manager that referenced this pull request Mar 3, 2022
motivation: When invoking any unknown or help-triggering `swift package` command in terminal, the suggested invocation always includes the `--enable-dependency-cache` flag. changes: useDependenciesCache flag to be non-optional, since this triggres a bug in argument parser which adds the option to the usage synopsis note: underlying issue fixed in apple/swift-argument-parser#416 rdar://89488586
tomerd added a commit to swiftlang/swift-package-manager that referenced this pull request Mar 4, 2022
motivation: When invoking any unknown or help-triggering `swift package` command in terminal, the suggested invocation always includes the `--enable-dependency-cache` flag. changes: useDependenciesCache flag to be non-optional, since this triggres a bug in argument parser which adds the option to the usage synopsis note: underlying issue fixed in apple/swift-argument-parser#416 rdar://89488586
@natecook1000
Copy link
Member Author

@swift-ci Please test

@natecook1000 natecook1000 merged commit c959b3a into main Mar 8, 2022
@natecook1000 natecook1000 deleted the nate/hide_optional_bool_flags branch March 8, 2022 00:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants