pong_custom_handler/
pong_custom_handler.rs

1use std::env::Args;
2use rusty_cli::runner::Runner;
3
4/// The method that is provided for the custom handler
5/// to handle the incoming data stream from the terminal
6/// NOTE: You need to provide the extra "ping" argument. Otherwise,
7/// the program will crash
8fn execute(mut args: Args) {
9    if args.len() > 0 {
10        if args.nth(1).unwrap() == "ping" {
11            println!("pong")
12        }
13    }
14}
15
16fn main() {
17    let mut runner = Runner::new();
18    runner.enable_custom_executor(execute);
19    runner.run();
20}