command_listener

Crates.iocommand_listener
lib.rscommand_listener
version0.1.0
created_at2025-06-11 21:48:50.115336+00
updated_at2025-06-11 21:48:50.115336+00
descriptionA command listener for handling commands in a Rust application
homepage
repositoryhttps://github.com/manhumor/command-listener
max_upload_size
id1709157
size5,786
Oleksandr (manhumor)

documentation

README

command-listener

its a simple command listener without any specifics

default commands:

  • exit -> stops the listener
  • list -> lists all commands

usage:

use command_listener::{Command, Listener};

fn main() {
    
    println!("Hello, command-listener!");

    // creating a command
    let test_command = Command::from(
        // name
        String::from("test"),
        // description
        String::from("this is a test command"),
        // execute function
        || {
            
            println!("This is a test command!");
        }
    );
    
    // creating a listener
    let mut listener = Listener::new();
    
    // adding the command to the listener
    listener.add_command(test_command);
    
    // listening for commands
    listener.listen();
}
Commit count: 1

cargo fmt