apple / swift-argument-parser

Straightforward, type-safe argument parsing for Swift
Apache License 2.0
3.31k stars 311 forks source link

AsyncParsableCommand documentation #561

Closed robertmryan closed 3 months ago

robertmryan commented 1 year ago

Right now, if you supply an async rendition of run() in conjunction with ParsableCommand, it produces no warning or error, but whenever you run the app, you simply see the “USAGE” text. It took a surprising/unnecessary amount of time pouring through the class library and looking at a particular code sample, before I stumbled across AsyncParsableCommand.

If you would like me to take a pass at a PR to that end, please let me know.

natecook1000 commented 1 year ago

Ideally, it would be great to produce a meaningful warning/error when a valid run() is not found. It obviously fell through to a point where “USAGE” text was displayed. Is it possible to give us some warning why we got the “USAGE” text?

I don't think we can detect that this is happening. Ideally Swift would warn for this near-miss implementation, but since the ParsableCommand protocol provides the default implementation for run(), there isn't an unsatisfied requirement to complain about.

I would suggest that the README.md and the documentation introduction make some reference to AsyncParsableCommand for async renditions of run(). This should be more easily discovered.

A PR for this would be great, thank you!

robertmryan commented 1 year ago

@natecook1000 - I have submitted PR https://github.com/apple/swift-argument-parser/pull/565 with an attempt to make AsyncParsableCommand more easily discovered. If you have suggestions you would like me to incorporate, please let me know.

Needless to say, feel free to make whatever changes you want. My intent was simply to move the ball forward.