Skip to content
This repository was archived by the owner on Jul 11, 2021. It is now read-only.

FssAy/command-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Command Engine [v3.0.1] Depreceated

Command Engine will be continued here

An engine to create your own command-line interpreter.

  • No dependencies (only sync)
  • Commands as user-defined structures
  • Asynchronous commands
  • Case sensitive commands
  • Positional arguments
  • Optional non-positional arguments
  • Partial "departure" from the conventions

Example

use command_engine::*;

struct MyCommand;

impl Command for MyCommand {
    (...)
}

fn main() {
    // Raw instruction in String 
    let raw = String::from("mycommand help");
    
    // Creating the Engine object and adding the command
    let mut engine = Engine::new()
        .add(MyCommand{});
    
    // Executing the instruction
    let out = engine.execute(&raw);
    
    println!("StatusCode: '{}'\n{}", out.result, out.message)
}

Async Example

use command_engine::*;
use command_engine::asynchronous::*;

struct MyAsyncCommand;

#[async_trait]
impl AsyncCommand for MyAsyncCommand {
    (...)
}

#[tokio::main]
async fn main() {
    let raw = String::from("mycommand help");

    let mut engine = AsyncEngine::new()
        .add(MyAsyncCommand{});

    let out = engine.execute(&raw).await;

    println!("StatusCode: '{}'\n{}", out.result, out.message);
}

About

Simple engine for executing custom commands.

Resources

License

Stars

Watchers

Forks

Languages