Crate cline [] [src]

The cline crate provides an API that allows users to register CLI commands with an execute and dynamic suggest callback to help implementing command line clients that support auto completion of commands

Getting started

The cline API works by creating an instance of the struct Cli and calling register, execute or complete on it

Create a new Cli object:

let mut cli = Cli::new();

Register a function:

cli.register(vec!["list", "files"], | args | { println!("called with: {:?}", args); });

Get suggestions for autocompletion:

cli.complete("l"); //returns vec!["list"]
cli.complete("list"); //returns vec!["files"]

Execute command aka call registered exec closure:

cli.exec("list files"); //calls the registered closure

Structs

Cli

Opaque struct holding the registered Commands

Enums

Direction
Key

Functions

cline_run

Helper function that emulates linux terminal behaviour for command completion based on the commands registered with the Cli struct passed to the function. Can be exited with Ctrl + c