1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

pub enum ProcessResult {

  Continue,
  Exit,

}

pub fn process_command(command: &str)
-> ProcessResult {

  match command {
    "bye" | "goodbye" |
    "exit" | "quit" => {
      return ProcessResult::Exit;
    },
    "hi" | "hello" => {
      println!("Hi, how can I help you?");
    }
    "help" => {
      println!("Available commands:");
      println!("hi, hello: Prints a greeting message");
      println!("bye, goodbye, exit, quit: Quit the program");
    },
    _ => {
      if command.is_empty() {
        println!("Please type a command.");
      } else {
        println!("Unknown command: {}", command);
      }
    }
  }

  ProcessResult::Continue

}