public Command AddCommand(Command command) { Command cmd = command; Commands.Add(cmd); return cmd; }
/// <summary> /// look in the list of commands /// </summary> /// <param name="cmdLine"> /// A <see cref="System.String"/> /// look for a command specified by this command line /// currently no arguments are expected, case not sensitive /// </param> /// <param name="command"> /// A <see cref="Command"/> /// returns found command /// </param> /// <returns> /// A <see cref="System.Boolean"/> /// returns true if command is found /// </returns> public bool FindCommand(string cmdLine, out Command command) { // remove leading blanks // get first word of the command (delimiter is blank) int idx_blank_0 = cmdLine.IndexOf(' '); string word_0; if (idx_blank_0 > 0) { word_0 = cmdLine.Substring(0, idx_blank_0); } else { word_0 = cmdLine; } // case not sensitive - convert everything to lower case string cmdLineLower = word_0.ToLower(); foreach (Command cmd in Commands) { string cmdNameLower = cmd.Name.ToLower(); if (cmdNameLower.Equals(cmdLineLower)) { command = cmd; return true; } } command = null; return false; }
public Command AddCommand(string name, string shortDesctiption, string description, Callback callback) { Command cmd = new Command(name, shortDesctiption, description, callback); Commands.Add(cmd); return cmd; }