swift-sh icon indicating copy to clipboard operation
swift-sh copied to clipboard

Missing support for async entry points

Open dimitribouniol opened this issue 2 years ago • 1 comments

It doesn't seem like async entry points work when using swift sh, at least at first glance. I initially noticed this when migrating from ParsableCommand to AsyncParsableCommand, and all of a sudden my command only printed usage information, but never ran. Unfortunately, adding an await to the entry point await YourCommand.main() doesn't work (non-async main() is preferred), though the likely proper solution is to implement something like in #163, but make sure async entry points are supported.

For those that land here, there is a workaround:

let group = DispatchGroup()
group.enter()
Task {
    await YourCommand.main()
    group.leave()
}
group.wait()

dimitribouniol avatar Feb 02 '23 07:02 dimitribouniol

I'm not a Swift guy anymore (sadly). So I missed this update to the language.

Also I haven't time to add it. The codebase isn't too taxing. Testing it locally is quite easy. I hope someone takes this on.

mxcl avatar Feb 02 '23 22:02 mxcl