User Tools

Site Tools


Sidebar

Nebol Software Projects:

.NET Class Libraries

Contact info:

johan@nebol.se

nebolintegration_console_commands

This is an old revision of the document!


NebolIntegration: NebolIntegration_Console_Commands - Utilising the built-in console commands

NebolIntegration supports NebolCommand and has a built-in command set ready for use.

Use like this: </code> public static Parser SetupParser() {

// get the built-in commands
var commands = new Commands(engine, config); 
Parser 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);

} </code>

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...");

} </code>

nebolintegration_console_commands.1636028905.txt.gz · Last modified: 2021/11/04 13:28 by nebol