static void ShowUsage() { Console.WriteLine("\n\rNAME\n\r{0} - Chassis validation utility.", appName); Console.WriteLine("\n\rSYNTAX\n\r{0} [-RunAll] [-RunTests] [-RunBatch] [-Help]", appName); Console.WriteLine("\n\rOPTIONS"); Console.WriteLine(string.Join(Environment.NewLine, ( from prop in typeof(CmUtilOption).GetProperties() let attr = prop.GetCustomAttributes(typeof(CmdOptionAttribute), true) .Cast <CmdOptionAttribute>().FirstOrDefault() where attr != null select string.Format("-{0} -{1} {2}", attr.LongName.PadRight(10), attr.ShortName, attr.Description) ))); Console.WriteLine("\n\rREMARKS\n\rAll available test cases: "); Console.WriteLine(string.Join(Environment.NewLine, CmTestRunner.GetAllTestCases())); }
static void Run(string commandLine) { CmUtilOption option = null; try { option = new CmdLineParser <CmUtilOption>().Parse(commandLine); } catch (CommandLineParsingException e) { Console.WriteLine(e.Message); ShowUsage(); return; } if (option.Parsed == 0) { ShowUsage(); return; } if (option.Parsed != 1) { Console.WriteLine("Only one option is allowed."); ShowUsage(); return; } if (option.Help) { ShowUsage(); } else if (option.RunAll) { CmTestRunner.RunAllTestCases(); } else if (option.RunBatch != null) { CmTestRunner.RunFromBatch(option.RunBatch); } else if (option.RunTests != null) { CmTestRunner.RunTestCases(option.RunTests); } }