Skip to content
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

Add AsyncParsableArguments to support validating async arguments #630

Open
luispadron opened this issue Apr 9, 2024 · 4 comments
Open
Assignees
Labels
wontfix This will not be worked on

Comments

@luispadron
Copy link

Currently to share arguments across commands you can create a ParsableArguments type which contains your arguments/options, and can use func validate() throws to validate the arguments.

This fails for things that must be validated in an async manner. We should consider adding an async API for validating or AsyncParsableArguments to support this.

@CrazyFanFan
Copy link

I just encountered the same problem.

@dcantah
Copy link
Member

dcantah commented Apr 11, 2024

Also just hit this.. thought I might've been holding it wrong. I can try and take a look

@dcantah dcantah self-assigned this Apr 11, 2024
@natecook1000 natecook1000 added the wontfix This will not be worked on label May 20, 2024
@natecook1000
Copy link
Member

Given the headaches and challenges around supporting the sync and async versions of run(), I'm reticent to provide another overload here. As a workaround, you can perform any async validation at the start of your async run() method – if you throw a ValidationError from there you'll get the same output as an error thrown from the validate() method.

If this workaround doesn't work for you, please let me know!

@luispadron
Copy link
Author

Yeah that works and it's what we do today but it lacks a few things:

  • the argument cannot have the correct type, because the async function is not supported. E.g we need to declare the argument as String for example and then validate it converts to whatever type we wanted.
  • this conversion needs to happen in all the commands which use that argument.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

4 participants