public static void processParams(commandLineEntry entry, String[] args) { String __line = ""; foreach (String arg in args) { __line = __line + arg + " "; } process(entry, __line); }
/// <summary> /// Processes the specified input and populates the entry /// </summary> /// <param name="entry">The entry.</param> /// <param name="input">The input.</param> public static void process(commandLineEntry entry, String input) { lock (commandLineLock) { try { input = input.Trim(); if (input.isNullOrEmpty()) { entry.format = commandLineFormat.emptyLine; entry.isEmptyLine = true; return; } if (input.StartsWith(commentPrefix)) { entry.commentedOut = true; entry.commentLine = input.removeStartsWith(commentPrefix); entry.format = commandLineFormat.onlyComment; return; } if (input.Contains(commentPrefix)) { var splits = imbSciStringExtensions.SplitOnce(input, commentPrefix); input = splits[0]; if (splits.Count > 1) { entry.commentLine = splits[1]; } } MatchCollection mtch = null; Match mtc = null; if (COMMANDFORMAT_OnlyCommand.IsMatch(input)) { entry.format = commandLineFormat.onlyCommand; entry.command = input; } else if (COMMANDFORMAT_CommandAndSpecialSufix.IsMatch(input)) { entry.format = commandLineFormat.onlyCommand; if (input.EndsWith(PARAM_WILLCARD)) { entry.command = input.removeEndsWith(PARAM_WILLCARD).Trim(); entry.specialFunction = commandLineSpecialFunction.askForParameters; } if (input.EndsWith(PARAM_HELP)) { entry.command = input.removeEndsWith(PARAM_HELP).Trim(); entry.specialFunction = commandLineSpecialFunction.helpOnCommand; } } else { if (input.Contains("=")) { mtch = COMMANDFORMAT_Explicit.Matches(input); mtc = mtch[0]; entry.command = mtc.Groups[1].Value; entry.format = commandLineFormat.explicitFormat; foreach (Capture cap in mtc.Groups[3].Captures) { if (!cap.Value.isNullOrEmpty()) { entry.parameterName.Add(cap.Value); } } foreach (Capture cap in mtc.Groups[4].Captures) { if (!cap.Value.isNullOrEmpty()) { entry.parameterValue.Add(cap.Value); } } } else { mtch = COMMANDFORMAT_Implicit.Matches(input); mtc = mtch[0]; entry.command = mtc.Groups[1].Value; entry.format = commandLineFormat.implicitFormat; foreach (Capture cap in mtc.Groups[3].Captures) { if (!cap.Value.isNullOrEmpty()) { entry.parameterValue.Add(cap.Value); } } } } } catch (Exception ex) { entry.isSyntaxError = true; entry.errorMessage = "Command syntax error:" + ex.Message; } if (entry.command.Contains(COMMANDPREFIX_SEPARATOR)) { var parts = entry.command.SplitSmart(COMMANDPREFIX_SEPARATOR, "", true); entry.command = parts.Last(); parts.Remove(entry.command); entry.prefix.AddRange(parts); } } }