This is a copy of the Github readme.
Find the original on https://github.com/automation-tasks-rs/dev_bestia_cargo_completion.

dev_bestia_cargo_completion

Full auto-completion for cargo-auto and automation_tasks_rs and partial auto-completion for cargo in bash
version: 2021.1230.1047 date: 2021-12-30 author: bestia.dev repository: GitHub

Lines in Rust code Lines in Doc comments Lines in Comments Lines in examples Lines in tests

crates.io Documentation crev reviews Lib.rs Licence Rust Hits

Hashtags: #rustlang #buildtool #developmenttool
My projects on Github are more like a tutorial than a finished product: bestia-dev tutorials.

Try it

Install the binary:

cargo install dev_bestia_cargo_completion

Save definition for auto_completion in bash:

complete -C "dev_bestia_cargo_completion" cargo

Start typing cargo b and press tab.
It should auto-complete to cargo build.
Congratulation! You just used auto-completion :-)

bash auto completion

Auto-completion in Debian bash is a great tool. You type the first letters, press tab and the word is auto-completed.
Bash can call an executable binary to return the available words. So it can be written in Rust. This can produce even better results as known as dynamic auto-completion.
For my knowledge cargo does not have auto-completion yet. There are many plans. It can take some time.
I will build what I need now. Something simple. It doesn't need to be perfect.
This is a great blog:
https://www.joshmcguigan.com/blog/shell-completions-pure-rust/

complete, the Linux command

The Linux command complete adds auto_completion definitions to bash.
But it is only for the current session. If you want to make it persistent add it to you ~/.bashrc file. Or to some other file that runs commands on initialization of the bash.

# list the definitions
complete
# delete a definition
complete -r cargo
# define a binary to auto-complete the command
complete -C "binary" command
# for example
complete -C "dev_bestia_cargo_completion" cargo

development

I choose this long name for my crate, because cargo-completion is a hot topic. Sooner or later someone will build it - officially. This is why I added the prefix dev_bestia_, because my web domain is bestia.dev. This way I have the guarantee of a unique name and leave the short name to the future official version.
Run

cargo install cargo-auto

and then list the user-defined automation tasks with

cargo auto

You can change the definition for bash auto-completion to point to the compilation of this project in development. So you can easy test the auto-completion while developing it.

complete -C "/home/luciano/rustprojects/dev_bestia_cargo_completion/target/debug/dev_bestia_cargo_completion" cargo

cargo crev reviews and advisory

We leave in times of danger with supply chain attacks.
It is recommended to always use cargo-crev
to verify the trustworthiness of each of your dependencies.
Please, spread this info.
You can also read reviews quickly on the web. Example for the crate num-traits:
https://web.crev.dev/rust-reviews/crate/num-traits/

Open-source and free as a beer

My open-source projects are free as a beer (MIT license).
I just love programming.
But I need also to drink. If you find my projects and tutorials helpful, please buy me a beer by donating to my PayPal.
You know the price of a beer in your local bar ;-)
So I can drink a free beer for your health :-)
Na zdravje! Alla salute! Prost! Nazdravlje! 🍻

//bestia.dev
//github.com/bestia-dev
//bestiadev.substack.com
//youtube.com/@bestia-dev-tutorials