Our great sponsors
-
ripgrep
ripgrep recursively searches directories for a regex pattern while respecting your gitignore
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
I've got great news. Adding/supporting shell completions with your Rust based CLI is very easy! Using the clap crate, we can generate shell completion scripts either at compile time, or provide a special option to allow users to generate shell completion scripts at run time on the fly.
Before I said that creating shell completion scripts was hard, but how hard? A popular command line tool ripgrep which has a moderately large CLI space (not huge, but not trivial either) has a Bash completion script that is 213 lines lone (as of v12.1.1)! That's just Bash. Other shells have similarly sized scripts. rustup which has a fairly large CLI space has a 1,110 line Bash script.
We'll be updating our grab-xkcd program from a previous post with the new code, but in order to clearly demonstrate the different methods and not conflict with the original article I will use two new branches completions-ct for compile time completions, and completions-rt for run time completions. If the reader is feeling froggy, you can combine the two!