Skip to content

Hide option group with new OptionGroup constructor #301

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

Merged
merged 2 commits into from
Apr 25, 2021

Conversation

miggs597
Copy link
Member

Second PR that is needed to fix --help for SwiftPM

Related PRs:

SwiftPM
ArgumentParser

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

Copy link
Member

@natecook1000 natecook1000 left a comment

Choose a reason for hiding this comment

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

This is a great start @miggs597! 👏🏻 Added some notes about a different way to do this that will let us avoid using the description property.

return "OptionGroup(*definition*)"
}
}
}

extension OptionGroup {
public init(_hidden: Bool) {
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a comment here that says what this does and includes (Experimental)? Just want to hint that people shouldn't actually use this, even though it's public.

@@ -31,6 +31,7 @@
@propertyWrapper
public struct OptionGroup<Value: ParsableArguments>: Decodable, ParsedWrapper {
internal var _parsedValue: Parsed<Value>
internal var _hidden: Bool?
Copy link
Member

Choose a reason for hiding this comment

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

Let's have this be non-optional, and just default to false. Can you call it something like _hiddenFromHelp?

Comment on lines 88 to 90
if let hidden = _hidden {
return "OptionGroup(*definition*) _hidden: \(hidden)"
}
Copy link
Member

Choose a reason for hiding this comment

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

This works, but we don't really want to pass configuration values through this type's string representation. Instead, let's add var _hiddenFromHelp: Bool { get } as a protocol requirement in ArgumentSetProvider, here: https://github.com/apple/swift-argument-parser/blob/main/Sources/ArgumentParser/Parsable%20Types/ParsableArguments.swift#L230

You can add a default implementation that always returns false, and then this type will have the customized version, defined above.

@natecook1000
Copy link
Member

@swift-ci Please test

@miggs597
Copy link
Member Author

Are we ready to merge @natecook1000?

@natecook1000
Copy link
Member

Looks good to me! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants