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

Requiring completion candidates configuration for all parameters #681

Open
rgoldberg opened this issue Nov 2, 2024 · 2 comments
Open

Requiring completion candidates configuration for all parameters #681

rgoldberg opened this issue Nov 2, 2024 · 2 comments

Comments

@rgoldberg
Copy link
Contributor

rgoldberg commented Nov 2, 2024

There should be some way to require all property wrapper attributes (@Argument, etc.) to have a completion: argument if Swift Argument Parser cannot autogenerate shell completion candidates.

Some command-line parameters are unable to have completion candidates offered (like an account name, an unconstrained number, etc.), so a new none case for CompletionKind.Kind & an associated CompletionKind.none static property should be added.

If a shell's completion system can nicely indicate the type, name, or other info about a non-completable argument or option value, or even flat-out reject invalid values (like characters that aren't digits for an integer argument), then the completion scripts generated for that shell should properly configure those features.

This detection should be optional at build time (given it's a new feature, I assume the default should be to not perform such detection).

If detection at compile time proves too onerous or impossible to implement, then this detection could be performed when a --strict (or otherwise named) flag is included in the command line used to generate a completion script (using the --generate-completion-script flag).

@natecook1000
Copy link
Member

It seems like we could support an environment variable that enables this more strict mode, so that as a tool author you could have that requirement validated. I believe we have an environment variable that disables the other command type validations that we do at runtime in debug mode by default, so there's precedent.

@rgoldberg
Copy link
Contributor Author

@natecook1000 Thanks for the feedback.

I probably won't get to this anytime soon, as there are more important SAP issues & issues for my project, but I wanted to document the idea for future reference.

I'll let you know if & when I think I'll try to tackle this, but it won't be before I finish a PR for #679.

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

No branches or pull requests

2 participants