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 auto completion for loco and cargo loco commands #1229

Open
andreystepanov opened this issue Jan 30, 2025 · 2 comments
Open

Add auto completion for loco and cargo loco commands #1229

andreystepanov opened this issue Jan 30, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@andreystepanov
Copy link

andreystepanov commented Jan 30, 2025

Feature Request

Is your feature request related to a problem? Please describe.

Currently there's no auto completion for CLI commands, and it would've been nice to have them. Especially for more complex commands such as:

cargo loco generate scaffold posts name:string title:string content:text ... --api

Describe the solution you'd like

I'm not sure if it would be possible to auto-generate them on the fly though, since there's a build step for cargo loco ... subcommand.

Maybe instead we can introduce loco completions [bash|zsh|fish|nushell|...] subcommand, that will output statically defined completions for specified shell.

Describe alternatives you've considered

Alternatively, all necessary auto completions can be contributed to designated repositories and later linked back in the documentation website somewhere in Installing section.

Here's my contribution to nushell/nu_scripts#1029, for those who uses Nushell.

@andreystepanov andreystepanov added the enhancement New feature or request label Jan 30, 2025
@jondot
Copy link
Contributor

jondot commented Jan 31, 2025

Hi @andreystepanov it sounds like you are experienced in this. Would you like to submit a PR that implements such completions? It also may be that clap has a feature flag for supporting some of it.

@andreystepanov
Copy link
Author

andreystepanov commented Jan 31, 2025

Yes, sure!

I have a few questions though:

  1. How stable the cargo loco subcommands and their flags are? Do you forsee any major changes, or it's more or less complete (from end-user perspective)?

  2. What is the source of truth for attribute types that can be used in cargo loco g (model|scaffold|migration) posts field:* subcommands?

I can see there's a loco-gen/src/mappings.json, but attributes defined in there are different from what user can see on the website.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants