public static void __TestGrabber__(bool debug = false){ InformationGrabber grabber = new InformationGrabber(); GUIController.LogOutput(grabber.SearchForTerm("tennis", debug)); }
/// <summary> /// Parses the respective command and determines what action to carry out /// </summary> public string Execute(bool test = false) { if (parsed) { return(parseResult); } parsed = true; (bool success, string expression, CommandType type)decodedCommand = this.DecodeCommand(); switch (decodedCommand.type) { case CommandType.MATHS_EXPRESSION: Tree tree = new Tree(decodedCommand.expression, this.debug); double result = tree.Calculate(); if (test) { parseResult = result.ToString(); } else { parseResult = $"The result of {command} is {result}"; } break; case CommandType.INFORMATION_LOOKUP: InformationGrabber grabber = new InformationGrabber(); if (test) { parseResult = decodedCommand.expression; } else { string grabbedData = grabber.SearchForTerm(decodedCommand.expression); if (grabbedData == "") { parseResult = $"I couldn't find any information about: {decodedCommand.expression}"; } else { parseResult = $"Here's what I could source from Wikipedia about {decodedCommand.expression}: {grabbedData}"; } } break; case CommandType.PROGRAM_EXECUTION: bool success = ProgramManager.OpenProgram(decodedCommand.expression); parseResult = $"{decodedCommand.expression} opened successfully: {success}"; break; } return(parseResult); }