Crates.io | tabby |
lib.rs | tabby |
version | 0.0.6 |
source | src |
created_at | 2021-08-18 10:38:25.161429 |
updated_at | 2021-10-01 05:05:14.177715 |
description | A fast, lightweight windows powershell tab completion library. |
homepage | |
repository | https://github.com/XtremeDevX/tabby |
max_upload_size | |
id | 438912 |
size | 116,854 |
Tabby will generate tab windows powershell tab completions for your command line application. It's incredibly easy to use and setup!
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 🥳.