/// <summary> /// Analyzes the arguments and displays an interface to the user. Kicks off the program. /// </summary> /// <param name="args">User input</param> public int Run(string[] args) { var app = new CommandLineApplication { Name = "Stryker", FullName = "Stryker: Stryker mutator for .Net", Description = "Stryker mutator for .Net", ExtendedHelpText = "Welcome to Stryker for .Net! Run dotnet stryker to kick off a mutation test run", HelpTextGenerator = new GroupedHelpTextGenerator() }; app.HelpOption(); var inputs = new StrykerInputs(); var cmdConfigHandler = new CommandLineConfigHandler(); cmdConfigHandler.RegisterCommandLineOptions(app, inputs); app.OnExecute(() => { // app started PrintStrykerASCIIName(); _configReader.Build(inputs, args, app, cmdConfigHandler); _loggingInitializer.SetupLogOptions(inputs); PrintStrykerVersionInformationAsync(); RunStryker(inputs); return(ExitCode); }); try { return(app.Execute(args)); } catch (CommandParsingException ex) { Console.Error.WriteLine(ex.Message); if (ex is UnrecognizedCommandParsingException uex && uex.NearestMatches.Any()) { Console.Error.WriteLine(); Console.Error.WriteLine("Did you mean this?"); Console.Error.WriteLine(" " + uex.NearestMatches.First()); } return(ExitCodes.OtherError); } }
/// <summary> /// Reads all config from json and console to fill stryker inputs /// </summary> /// <param name="args">Console app arguments</param> /// <param name="app">The console application containing all argument information</param> /// <param name="cmdConfigHandler">Mock console config handler</param> /// <returns>Filled stryker inputs (except output path)</returns> public void Build(IStrykerInputs inputs, string[] args, CommandLineApplication app, CommandLineConfigHandler cmdConfigHandler) { // set basepath var basePath = Directory.GetCurrentDirectory(); inputs.BasePathInput.SuppliedInput = basePath; // read config from json and commandline var configFilePath = Path.Combine(basePath, cmdConfigHandler.GetConfigFilePath(args, app)); if (File.Exists(configFilePath)) { JsonConfigHandler.DeserializeConfig(configFilePath, inputs); } cmdConfigHandler.ReadCommandLineConfig(args, app, inputs); }