#clap #interactive #structopt #cli

slaps

Interactive shell interface using your existing Clap/StructOpt config

3 releases

0.2.3 Jul 27, 2020
0.2.2 Jul 26, 2020
0.2.1 Jul 26, 2020
0.2.0 Jul 25, 2020

#8 in #structopt

WTFPL license

135KB
3K SLoC

Crates.io Documentation GitHub Workflow Status Coveralls github

Slaps adds an interactive CLI mode to your Rust command-line applications using your existing Clap configuration.

It combines Clap with rustyline to provide line editing, auto-completion and syntax highlighting.

Example

This:

use slaps::Slaps;

// Using structopt
Slaps::with_name("slaps")
    .command(RekeyCommand::clap(), |args| Ok(()))
    .command(AccountCommand::clap(), |args| Ok(()))
    .command(UndoCommand::clap(), |args| Ok(()))
    .run()?;

Gets you this:

Terminal screenshot

Zero extra configuration needed.

Notes

This project is currently in early stages of development and any changes are motivated by it being part of my personal toolkit to quickly build Rust command-line applications. Most of it was extracted wholesale from the first project I built while learning Rust. It abuses the hell out of Clap's doc(hidden) internals to minimise the overhead of the glue code holding everything together. This makes things likely to break with future versions of Clap. You have been warned, your warranty is now void, etc.

Dependencies

~7MB
~128K SLoC