示例#1
0
        public static int Main(string[] Args)
        {
            var definition = new ArgumentDefinition(new HtmlReportArguments().GetType());
            var parser     = new GNUArgumentParser();

            int exitCode = 0;

            try
            {
                var arguments = parser.Parse <HtmlReportArguments>(definition, Args);

                string cssCode = ReadAllText(arguments.CssPath);
                var    reports = new List <TestReport>();
                foreach (var reportPath in arguments.ReportPaths)
                {
                    reports.Add(ParseReport(reportPath));
                }
                var htmlDoc = CreateComparisonHtml(cssCode, reports);
                htmlDoc.Save(Console.Out);
                Console.WriteLine();
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("error: {0}", ex.Message);
                Console.Error.Write("usage: {0}", parser.GenerateUsageString(definition));

                exitCode = 1;
            }
            return(exitCode);
        }
        public static CommandLineArguments ParseArguments(string[] argArray)
        {
            // create container definition and the parser
            var definition = new ArgumentDefinition(typeof(CommandLineArguments));
            var parser     = new GNUArgumentParser();

            CommandLineArguments arguments = null;

            try
            {
                // create object with the populated arguments
                arguments = parser.Parse <CommandLineArguments>(definition, argArray);
            }
            catch (System.Exception ex)
            {
                Console.Error.WriteLine($"Error: {ex.Message}");
                Console.Error.Write(GetUsageString());

                throw;
            }
            return(arguments);
        }