Skip to content

[Option] Support MultiArg options #1609

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

Conversation

cachemeifyoucan
Copy link
Contributor

Teach SwiftOption to handle MultiArg options, including generating Options from Options.td, etc. Even the only MultiArg option in swift is a NoDriver option, still teach the OptionTable to parse such options to future proof the implementation.

@cachemeifyoucan
Copy link
Contributor Author

needed to support: swiftlang/swift#73601

@cachemeifyoucan
Copy link
Contributor Author

@swift-ci please test

@cachemeifyoucan cachemeifyoucan force-pushed the eng/PR-multi-arg-support branch from 143899e to 8e42d4c Compare May 14, 2024 00:21
@cachemeifyoucan
Copy link
Contributor Author

@swift-ci please test

@cachemeifyoucan
Copy link
Contributor Author

@swift-ci please test windows platform

}
let endIdx = index + Int(option.numArgs)
parsedOptions.addOption(option, argument: .multiple(Array()))
arguments[index..<endIdx].map { String($0) }.forEach { parsedOptions.addInput($0) }
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this index off the end of the array if the user doesn't provide enough args?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Added a testcase for that too.

Teach SwiftOption to handle MultiArg options, including generating
Options from Options.td, etc. Even the only MultiArg option in
swift is a NoDriver option, still teach the OptionTable to parse such
options to future proof the implementation.
@cachemeifyoucan cachemeifyoucan force-pushed the eng/PR-multi-arg-support branch from 8e42d4c to 62c300b Compare May 14, 2024 16:41
@cachemeifyoucan
Copy link
Contributor Author

@swift-ci please test

@cachemeifyoucan cachemeifyoucan merged commit 43828dd into swiftlang:main May 14, 2024
3 checks passed
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.

3 participants