Skip to content

Conversation

@natecook1000
Copy link
Member

@natecook1000 natecook1000 commented May 21, 2020

Description

This brings the main() method in line with using the new @main attribute on the root
command type.

Detailed Design

The changes here are to make ParsableCommand.main() a Void-returning function, to break out a separate no-argument version, and to remove the default parameter. The default-argument version doesn't satisfy the () -> Void requirement for @main.

The main() method now returns without exiting on successful execution of a

Documentation Plan

No real impact. Documentation for using @main with the library to follow.

Test Plan

All existing tests continue to pass. SwiftPM will need an update to support @main in executable targets.

Source Impact

Typical code should continue to behave as expected, but this is source-breaking if anyone has a strongly-typed usage of ParsableCommand.main(), e.g. let mainFunction: ([String]?) -> Never = MyCommand.main. Keeping the old version with a deprecation/unavailability annotation isn't possible, since there would be ambiguity between that and the new ones.

In addition, code that followed MyCommand.main() in main.swift is no longer dead code, and will be executed after successful execution of the command.

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

This provides support for using the `@main` attribute on the root
command type.
@natecook1000
Copy link
Member Author

@swift-ci Please test

@natecook1000 natecook1000 merged commit 4c07125 into master Jun 1, 2020
@natecook1000 natecook1000 deleted the nate/never_never branch June 1, 2020 21:13
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