JoshMcguigan / shell_completion

Write shell completion scripts in pure Rust
Apache License 2.0
133 stars 6 forks source link

derive completion scripts #3

Open JoshMcguigan opened 5 years ago

JoshMcguigan commented 5 years ago

For users of popular Rust CLI arg parsing libraries, could we implement a #[derive(ShellCompletion)] macro?

This would provide a lot of value to the Rust community by reducing the effort required to add shell completions to a Rust CLI to almost zero.

pickfire commented 5 years ago

An integration with clap would be cool as well.

amitsaha commented 5 years ago

hi @JoshMcguigan - thanks for your recent article (related to this project). I got started with it to understand bash completion and then I thought what would be cool is to be able to make a command itself also handle its own auto-completion. When using a CLI framework, our app is already aware of it's own sub-commands/commands and flags, we should be able to achieve auto-completion from the app itself. I shared some code with a specific CLI framework in Golang (https://github.com/spf13/cobra/issues/867) and see what folks have to say. I imagine, you are thinking of something similar for rust ecosystem? If so, that is, if we make the program itself handle the functionality of shell completion, why do we need compgen or this project? I don't mean to question your project's goals/need, but just want to understand - since I am just getting my feet in in this area.

Thanks.

JoshMcguigan commented 5 years ago

Hi @amitsaha, thanks for the question. This project (at the moment) provides low level primitives for writing completion scripts. Something I am looking into is whether we can add functionality to derive completion scripts automatically if, for example, the user is using structopt or some other popular rust CLI framework. In this case, the user may not be aware of the low level primitives in this crate, but they would be getting used to provide completions. In short, this project at the moment is working on laying the groundwork to make it easier to do what you are describing.

amitsaha commented 5 years ago

Makes sense, thanks @JoshMcguigan