Open JoshMcguigan opened 5 years ago
An integration with clap would be cool as well.
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.
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.
Makes sense, thanks @JoshMcguigan
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.