private int ExecuteKeywordsForAsync(IConsole console) { if (KnownData.TryGetProvider(KeywordsForProvider, out var provider)) { console.WriteLine($"Known keywords for {provider.Name} ({provider.Guid}):"); foreach (var keyword in provider.Keywords.Values) { console.WriteLine($"* 0x{keyword.Value:x16} {keyword.Name}"); } return(0); } else { console.WriteLine($"There are no known keywords for {KeywordsForProvider}."); return(1); } }
private static bool TryParseKeywords(string input, string provider, out ulong keywords) { if (string.Equals("*", input, StringComparison.Ordinal)) { keywords = ulong.MaxValue; return(true); } else if (input.StartsWith("0x")) { // Keywords if (ulong.TryParse(input, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out keywords)) { return(true); } } else if (KnownData.TryGetProvider(provider, out var knownProvider)) { var splat = input.Split(','); keywords = 0; foreach (var item in splat) { if (knownProvider.Keywords.TryGetValue(item, out var knownKeyword)) { keywords |= knownKeyword.Value; } else { throw new CommandLineException($"Keyword '{item}' is not a well-known keyword for '{provider}'"); } } return(true); } keywords = ulong.MaxValue; return(false); }