Crates.io | console-prompt |
lib.rs | console-prompt |
version | 0.1.5 |
source | src |
created_at | 2023-03-29 00:24:12.926344 |
updated_at | 2023-06-11 04:02:47.136101 |
description | console_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 | |
repository | https://github.com/deadjakk/console-prompt |
max_upload_size | |
id | 823567 |
size | 548,612 |
A very simple way to make a clean, thread-safe, interactive CLI interface in rust.
Running example:
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.