6 releases
0.1.0 |
|
---|---|
0.0.6 | Oct 1, 2021 |
0.0.5 | Aug 22, 2021 |
#539 in Configuration
115KB
152 lines
A fast, lightweight windows powershell tab completion library.
About
Tabby will generate tab windows powershell tab completions for your command line application. It's incredibly easy to use and setup!
Usage
Let's get setup so you can start tab ing away!
Here's the basic usage of tabby
.
Step 1. Setup Your Completer
use std::path::Path;
use tabby::{setup::verify_setup, Completer};
fn main() {
// Collect input args
let args = std::env::args().collect::<Vec<String>>();
if args.len() > 1 {
// This part is required for tabby to work..
if args[1] == "complete" {
// create a new tabby completer
// the path should be the absolute path to your tabby config (we'll get to this soon). Without an absolute path, tabby will not work.
let completer = Completer::new(Path::new(
r"C:\Users\myname\dev\mycli\tabby.config.json",
))
.unwrap();
// if you can't verify that tabby has installed a completer for your command line application, install tab completion.
if !verify_setup(&completer).unwrap() {
completer.install().unwrap();
}
// get completions for your command line applications
let completions = completer.get_completions();
// you must print the completions for powershell to be able to detect your completions.
println!("{}", completions);
}
}
}
Step 2. Write Completions
Now, we'll be setting up tabby.config.json
. Your tabby configuration will contain the completions that tabby will be able to complete. This should be the same path as your absolute path that you used in the previous step.
{
"name": "your-cli-exe-name-without-the-.exe-extension",
"commands": [
{
"name": "acustomcommand",
"flags": [
"--aflag",
"--anotherflag"
]
},
{
"name": "anothercustomcommand",
"flags": [
"--verbose",
"--debug"
]
},
]
}
Step 3. Write Completions
Phew! We're almost done. Now for 1 final simple step.
Add your executable to PATH
through your System Environment Variables
.
That's it! We're done. Enjoy your tab completions 🥳.
Dependencies
~0.5–7.5MB
~56K SLoC