Skip to content

Handle subcommands #28

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 1 commit into from
Nov 8, 2019
Merged

Handle subcommands #28

merged 1 commit into from
Nov 8, 2019

Conversation

sjavora
Copy link
Contributor

@sjavora sjavora commented Oct 26, 2019

This tries to implement the handling of subcommands based on the original driver. I must admit I'm a little out of my depth here so I'd appreciate some guidance:

  • in the original driver, the subcommand check happens before the actual driver is even created (here) - I put the code in the init, because the FIXME was there, but should an init be invoking exec?
  • related to the above, is exec the right function to use here?
  • similarly, is Process.findExecutable the right method to use in place of getExecutablePath?
  • there is a slight difference in behavior between llvm::sys::path::stem and basenameWithoutExt - namely basenameWithoutExt will return .txt for /foo/.txt, while llvm::sys::path::stem will return an empty string. Is this a problem? If so, should I implement something like stem on VirtualPath?

Thank you very much for your time 🙂


self.diagnosticEngine = DiagnosticsEngine(handlers: [diagnosticsHandler])

if case .subcommand = try Self.invocationRunMode(forArgs: args) {
diagnosticEngine.emit(.error_subcommand_in_driver)
Copy link
Member

Choose a reason for hiding this comment

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

I think we should throw here, so we don't continue trying to parse the rest of the command line.

Copy link
Contributor Author

@sjavora sjavora Nov 6, 2019

Choose a reason for hiding this comment

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

Sure thing, but then we can't check the exact error type in the tests, since Driver.Error is internal - should it be made public?

Alternatively, we could add descriptions to the errors and match those, but I tried overriding implementing localizedDescription and it was not called for some reason.

Copy link
Contributor

@harlanhaskins harlanhaskins left a comment

Choose a reason for hiding this comment

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

LGTM!

@harlanhaskins
Copy link
Contributor

@swift-ci please test

@sjavora
Copy link
Contributor Author

sjavora commented Nov 8, 2019

@DougGregor is there anything else I should change here?

Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

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

Looks great, thank you!

@DougGregor DougGregor merged commit 74980ca into swiftlang:master Nov 8, 2019
@sjavora sjavora deleted the subcommands branch February 6, 2021 12:48
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