public static int Run(InvocationContext context) { string defaultNamespace = context.ParseResult.ValueForOption <string>("--defaultNamespace"); string scraperOutputDir = context.ParseResult.ValueForOption <string>("--scraperOutputDir"); var excludeItems = context.ParseResult.ValueForOption <string[]>("--exclude"); var enumJsonFiles = context.ParseResult.ValueForOption <string[]>("--enumsJson"); var headerTextFile = context.ParseResult.ValueForOption <string>("--headerTextFile"); var requiredNamespaceValuePairs = context.ParseResult.ValueForOption <string[]>("--requiredNamespaceForName"); var traversedHeaderToNamespaceValuePairs = context.ParseResult.ValueForOption <string[]>("--traversedFileToNamespace"); var remappedNameValuePairs = context.ParseResult.ValueForOption <string[]>("--memberRemap"); var withTypeValuePairs = context.ParseResult.ValueForOption <string[]>("--with-type"); var withAttributeValuePairs = context.ParseResult.ValueForOption <string[]>("--with-attribute"); var exclusionNames = new HashSet <string>(excludeItems ?? (new string[0])); Dictionary <string, string> traversedHeadersToNamespaces = ConvertValuePairsToDictionary(traversedHeaderToNamespaceValuePairs); Dictionary <string, string> requiredNamespaces = ConvertValuePairsToDictionary(requiredNamespaceValuePairs); Dictionary <string, string> remaps = ConvertValuePairsToDictionary(remappedNameValuePairs); Dictionary <string, string> withTypes = ConvertValuePairsToDictionary(withTypeValuePairs); Dictionary <string, string> withAttributes = ConvertValuePairsToDictionary(withAttributeValuePairs); var headerText = !string.IsNullOrEmpty(headerTextFile) ? File.ReadAllText(headerTextFile) : string.Empty; // Always exclude this exclusionNames.Add("__cplusplus"); ScraperResults results; try { results = ConstantsScraper.ScrapeConstants( enumJsonFiles, defaultNamespace, scraperOutputDir, headerText, exclusionNames, traversedHeadersToNamespaces, requiredNamespaces, remaps, withTypes, withAttributes); } catch (System.Exception e) { context.Console.Out.Write($"Failed to scrape constants:\r\n{e.Message}\r\n{e.StackTrace}"); return(-1); } foreach (var item in results.Output) { context.Console.Out.Write(item); context.Console.Out.Write("\r\n"); } return(0); }
public static int Run(InvocationContext context) { string repoRoot = context.ParseResult.ValueForOption <string>("repoRoot"); string arch = context.ParseResult.ValueForOption <string>("arch"); var excludeItems = context.ParseResult.ValueForOption <string[]>("exclude"); var enumJsonFiles = context.ParseResult.ValueForOption <string[]>("enumsJson"); var headerTextFile = context.ParseResult.ValueForOption <string>("headerTextFile"); var requiredNamespaceValuePairs = context.ParseResult.ValueForOption <string[]>("requiredNamespaceForName"); var remappedNameValuePairs = context.ParseResult.ValueForOption <string[]>("remap"); var withTypeValuePairs = context.ParseResult.ValueForOption <string[]>("with-type"); var withAttributeValuePairs = context.ParseResult.ValueForOption <string[]>("with-attribute"); var exclusionNamesToPartitions = ConvertExclusionsToDictionary(excludeItems); var requiredNamespaces = ConvertValuePairsToDictionary(requiredNamespaceValuePairs); var remaps = ConvertValuePairsToDictionary(remappedNameValuePairs); var withTypes = ConvertValuePairsToDictionary(withTypeValuePairs); var withAttributes = ConvertValuePairsToDictionary(withAttributeValuePairs); var headerText = !string.IsNullOrEmpty(headerTextFile) ? File.ReadAllText(headerTextFile) : string.Empty; ScraperResults results; try { results = ConstantsScraper.ScrapeConstants( repoRoot, arch, enumJsonFiles, headerText, exclusionNamesToPartitions, requiredNamespaces, remaps, withTypes, withAttributes); } catch (System.Exception e) { context.Console.Out.Write($"Failed to scrape constants:\r\n{e.Message}\r\n"); return(-1); } foreach (var item in results.Output) { context.Console.Out.Write(item); context.Console.Out.Write("\r\n"); } return(0); }