NebolIntegration supports NebolCommand and has a built-in command set ready for use.
NOTE: This functionality has been moved into its own class library: NebolIntegration.Console
Use like this:
public static Parser SetupParser() { // get the built-in commands var commands = new Commands(engine, config); var parser = new Parser(); // add the commands from the Commands class parser.Commands.AddRange(commands.CommandList); // I'm adding an extra command, for exiting the application parser.Commands.Add(new Command { Name = "exit", AlternateName = "x", ShortDescription = "exit the application gracefully", ExecuteDelegate = new ExecuteDelegate(item => Quit()) }); return (parser); }
Main loop:
var parser = SetupParser(); Console.WriteLine("Ready. Type ? for help."); while (!shutdown) { Console.Write("> "); string s = Console.ReadLine(); if (string.IsNullOrEmpty(s)) Console.WriteLine("Type help to list all commands."); else parser.Parse(s); }
public static void Quit() { shutdown = true; Console.WriteLine("Shutting down of application has begun..."); }