yogurt

Crates.ioyogurt
lib.rsyogurt
version0.3.1
sourcesrc
created_at2022-06-19 08:39:15.882312
updated_at2022-06-26 09:01:38.929338
descriptionA simple command system
homepage
repositoryhttps://github.com/Treesoid/yogurt
max_upload_size
id608864
size27,745
(Treesoid)

documentation

README

yogurt

Yogurt is a rust command library.

Example:

use yogurt::argument::parser::IntArgument;
use yogurt::{Command, Dispatcher};

fn main() {
    // Create a dispatcher
    let dispatcher = Dispatcher::builder()
        // command prefix, defaults to none
        .prefix("/")
        // context factory, new context is created for every executed command
        .context(Box::new(|| ()))
        .child(
            Command::literal("ping").child(
                Command::argument("number", IntArgument, true).exec(Box::new(|ctx| {
                    println!("{:?}", ctx);
                    Ok(())
                }))
            )
        )
        .build()
        // fails if no context factory provided
        .unwrap();
    
    // run command
    dispatcher.run_command("/ping 3").unwrap();
}
Commit count: 33

cargo fmt