예제 #1
0
        public static string GetUsageString()
        {
            var definition = new ArgumentDefinition(typeof(CommandLineArguments));
            var parser     = new GNUArgumentParser();

            return($"Usage: {parser.GenerateUsageString(definition)}");
        }
예제 #2
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);
        }
예제 #3
0
        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);
        }