/// <summary> /// Parses the args into individual options /// </summary> /// <param name="Args">Args to parse</param> /// <returns>A list of options</returns> public virtual List <Option> Parse(string[] Args) { if (Args == null) { return(new List <Option>()); } List <Option> Result = new List <Option>(); string Text = ""; string Splitter = ""; foreach (string Arg in Args) { Text += Splitter + Arg; Splitter = " "; } MatchCollection Matches = OptionRegex.Matches(Text); string Option = ""; foreach (Match OptionMatch in Matches) { if (OptionMatch.Value.StartsWith(OptionStarter) && !string.IsNullOrEmpty(Option)) { Result.Add(new Option(Option, OptionStarter)); Option = ""; } Option += OptionMatch.Value + " "; } Result.Add(new Option(Option, OptionStarter)); return(Result); }
/// <inheritdoc/> public override object VisitOptionDefinition([NotNull] LGFileParser.OptionDefinitionContext context) { var originalText = context.OPTION().GetText(); var result = string.Empty; if (!string.IsNullOrWhiteSpace(originalText)) { var matchResult = OptionRegex.Match(originalText); if (matchResult.Success && matchResult.Groups.Count == 2) { result = matchResult.Groups[1].Value?.Trim(); } } if (!string.IsNullOrWhiteSpace(result)) { _templates.Options.Add(result); } return(null); }