console-prompt

Crates.ioconsole-prompt
lib.rsconsole-prompt
version0.1.5
sourcesrc
created_at2023-03-29 00:24:12.926344
updated_at2023-06-11 04:02:47.136101
descriptionconsole_prompt is a very simple library for creating clean, thread-safe cli prompts for interactive cli programs in rust heavily relying on crossterm. I created this for a C2 client, but it could likely be used in anywhere you want an interactive prompt. The simplicity of it is what I think sets it apart from other projects
homepage
repositoryhttps://github.com/deadjakk/console-prompt
max_upload_size
id823567
size548,612
(deadjakk)

documentation

README

console_prompt

A very simple way to make a clean, thread-safe, interactive CLI interface in rust.

Running example:

Example GIF

Creating a prompt is as simple as creating a vector of Command structs with pointers to your functions and handing them off to command_loop:

fn main(){
    let commands = vec![
        Command{
            command: "converse",
            func: converse, // <---- pointer to the converse function
            help_output: "converse <name> - interact with a person"
        },
    ];

    // start the command loop with the provided commands
    if let Err(e) = command_loop(&commands, &mut DynamicContext::new()){
        eprintln!("error running command loop: {}", e.to_string());
    }
}

You can also create nested command_loops that maintain state via the context argument, see the conversation example for more info.

Currently this does not support windows due to limitations with windows terminal. If someone asks for windows support i'll try and figure something out.

Commit count: 15

cargo fmt