public bool Parse() { bool result = false; try { List <string> commands = parser.Parse(input); CLICommand lastCommand = null; foreach (string cmd in commands) { if (cmd[0] == '-') { string command = cmd.Substring(1); lastCommand = new CLICommand(command); Commands.Add(lastCommand); } else if (lastCommand != null && string.IsNullOrEmpty(lastCommand.Parameter)) { lastCommand.Parameter = cmd; } else { throw new Exception("Command not starting with '-' or more than one parameter exist."); } } result = true; } catch (Exception e) { DebugHelper.WriteException(e); } return(result); }
public bool Parse() { bool result = false; try { List<string> commands = parser.Parse(input); CLICommand lastCommand = null; foreach (string cmd in commands) { if (cmd[0] == '-') { string command = cmd.Substring(1); lastCommand = new CLICommand(command); Commands.Add(lastCommand); } else if (lastCommand != null && string.IsNullOrEmpty(lastCommand.Parameter)) { lastCommand.Parameter = cmd; } else { throw new Exception("Command not starting with '-' or more than one parameter exist."); } } result = true; } catch (Exception e) { DebugHelper.WriteException(e); } return result; }