#make #rust

app dev_bestia_cargo_completion

Full auto-completion for cargo-auto and automation_tasks_rs and partial auto-completion for cargo in bash

1 stable release

2021.1230.1047 Dec 30, 2021
2021.819.909 Aug 19, 2021
2021.817.1756 Aug 17, 2021

#65 in Build Utils

32 downloads per month

MIT license

52 lines


Full auto-completion for cargo-auto and automation_tasks_rs and partial auto-completion for cargo in bash
repository; version: 2021.1230.1047 date: 2021-12-30 authors: Luciano Bestia

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

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:

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
# 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


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.

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:

open-source free and free as a beer

My open-source projects are free and 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 or two donating on 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 !