-
Notifications
You must be signed in to change notification settings - Fork 354
Augment Option to support default value #830
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
base: main
Are you sure you want to change the base?
Conversation
d08351c to
61a6602
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- xctest instead of swift-testing to support swift 5.7
- synopsis:
[--log-level [log-level]]or[--log-level [<log-level>]] - dump-help snapshot tests
- completion snapshot tests
- manpage support
- manpage snapshot tests
- documentation
|
Would it make more sense instead to provide this functionality via @Option(parsing: .scanningForValue(default: "text"))
var showBinPath: String?You'd add/modify the following (I haven't checked the code for proper generics/types/compilation/keywords/etc.; it's just pseudo-code to illustrate the concept. I also haven't checked to see what problems adding the new public struct SingleValueParsingStrategy: Hashable {
…
// This is an addition
public static func scanningForValue<Value>(default: Value) -> SingleValueParsingStrategy {
self.init(base: .scanningForValue(default: default))
}
…
}
struct ArgumentDefinition {
…
enum ParsingStrategy {
…
// This is a modification
case scanningForValue(default: Any? = nil)
…
}
…
}One possible issue: must ensure that the option terminator cmd --show-bin-path -- json |
|
Thanks for the feedback @rgoldberg . What you proposed makes more sense than what I implemented. |
61a6602 to
b319a92
Compare
There is a need to have an option argument to behave like a flag in some cases. In order to prevent conflicting values between property initialization and parsing strategy, a fatalError is raised with an apppropriate message. Ideally, we would have raised a compile-time error, as `SingleValueParsingStrategy` values are determined at runtime. This change augments `Option` to support this. Fixes: #829
b319a92 to
2316d12
Compare
There is a need to have an option argument to behave like a flag in some cases. In order to prevent conflicting values between property initialization and parsing strategy, a
fatalErroris raised with an appropriate message.Ideally, we would have raised a compile-time error, but
SingleValueParsingStrategyvalues are determined at runtime.This change augments
Optionto support this.Fixes: #829
Checklist