tabby

Crates.iotabby
lib.rstabby
version0.0.6
sourcesrc
created_at2021-08-18 10:38:25.161429
updated_at2021-10-01 05:05:14.177715
descriptionA fast, lightweight windows powershell tab completion library.
homepage
repositoryhttps://github.com/XtremeDevX/tabby
max_upload_size
id438912
size116,854
Tejas Ravishankar (suptejas)

documentation

README

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 🥳.

Commit count: 0

cargo fmt