Skip to content

SwiftSyntaxTest: refactor command-line argument parsing into a test utility module. NFC #18418

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 4 commits into from
Aug 1, 2018

Conversation

nkcsgexi
Copy link
Contributor

No description provided.

@nkcsgexi
Copy link
Contributor Author

@swift-ci please smoke test

@nkcsgexi nkcsgexi requested a review from ahoppen July 31, 2018 22:10
Copy link
Member

@ahoppen ahoppen 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 overall. I knew this was going to come up so thanks for tackling it.
Some minor accessibility comments below.

let argName: String

var errorDescription: String? {
return "Missing required argument: \(argName)"
}
}
struct UnkeyedArgumentError: LocalizedError {
fileprivate struct UnkeyedArgumentError: LocalizedError {
Copy link
Member

Choose a reason for hiding this comment

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

IMHO this should be public so that you can specifically catch the error. Same goes for MissingArgumentError.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, will update!

let argName: String

var errorDescription: String? {
return "Unexpectedly found command line argument \(argName) without a key"
}
}

private let args: [String: String]
fileprivate let args: [String: String]
Copy link
Member

Choose a reason for hiding this comment

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

Is there any reason why this an no longer be private?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not specifically; keeping it as private should be good enough.

Copy link
Member

Choose a reason for hiding this comment

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

I always default to private because its less verbose and the stricter access level.

@nkcsgexi
Copy link
Contributor Author

@swift-ci please smoke test

@nkcsgexi
Copy link
Contributor Author

@ahoppen do you mind if we change the flag style from "--flag" to "-flag" to match the conventions?

@ahoppen
Copy link
Member

ahoppen commented Jul 31, 2018

do you mind if we change the flag style from "--flag" to "-flag" to match the conventions?

No, I don't have strong opinions on this.

@nkcsgexi
Copy link
Contributor Author

@swift-ci please smoke test

@nkcsgexi nkcsgexi merged commit 571b29b into swiftlang:master Aug 1, 2018
@nkcsgexi nkcsgexi deleted the refactor-arg-parse branch August 1, 2018 00:05
ahoppen pushed a commit to ahoppen/swift that referenced this pull request Aug 22, 2018
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