/// <inheritdoc /> protected override int RunImpl(string[] args) { if (!ParseArguments(args)) { ShowHelp(); return(1); } if (Arguments.Help) { ShowHelp(); return(0); } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var runtimeSetup = new RuntimeSetup(); GenericCollectionUtils.ForEach(Arguments.PluginDirectories, x => runtimeSetup.AddPluginDirectory(x)); ILogger logger = new FilteredLogger(new RichConsoleLogger(Console), Verbosity.Normal); using (RuntimeBootstrap.Initialize(runtimeSetup, logger)) { IControlPanelPresenter presenter = RuntimeAccessor.Instance.ServiceLocator.Resolve <IControlPanelPresenter>(); presenter.Show(null); } return(0); }
protected override int RunImpl(string[] args) { if (!ParseArguments(args)) { ShowHelp(); return(1); } if (Arguments.Help) { ShowHelp(); return(0); } RuntimeSetup runtimeSetup = new RuntimeSetup(); runtimeSetup.RuntimePath = runtimePath; foreach (string pluginDirectory in Arguments.PluginDirectories) { runtimeSetup.AddPluginDirectory(pluginDirectory); } RichConsoleLogger runtimeLogger = new RichConsoleLogger(Console); FilteredLogger filteredLogger = new FilteredLogger(runtimeLogger, Arguments.Verbosity); RuntimeBootstrap.Initialize(runtimeSetup, filteredLogger); runtimeLogger.Log(LogSeverity.Important, "This program is a stub..."); return(0); }
protected override void ShowHelp() { // Show argument only help first because what we do next might take a little while // and we want to make the program appear responsive. base.ShowHelp(); // Print out options related to the currently available set of plugins. var setup = new RuntimeSetup(); if (Arguments != null && Arguments.PluginDirectories != null) { GenericCollectionUtils.ForEach(Arguments.PluginDirectories, x => setup.AddPluginDirectory(x)); } using (RuntimeBootstrap.Initialize(setup, CreateLogger())) { IReportManager reportManager = RuntimeAccessor.ServiceLocator.Resolve <IReportManager>(); ShowRegisteredComponents("Supported report types:", reportManager.FormatterHandles, h => h.GetTraits().Name, h => h.GetTraits().Description); ITestRunnerManager runnerManager = RuntimeAccessor.ServiceLocator.Resolve <ITestRunnerManager>(); ShowRegisteredComponents("Supported runner types:", runnerManager.TestRunnerFactoryHandles, h => h.GetTraits().Name, h => h.GetTraits().Description); } }
/// <inheritdoc /> protected override int RunImpl(string[] args) { ShowBanner(); InstallCancelHandler(); if (!ParseArguments(args) || Arguments.CommandAndArguments.Length == 0) { ShowHelp(); return(Arguments.Help ? 0 : 1); } ILogger logger = CreateLogger(); IProgressMonitorProvider progressMonitorProvider = Arguments.NoProgress ? (IProgressMonitorProvider)NullProgressMonitorProvider.Instance : new RichConsoleProgressMonitorProvider(Console); string commandName = Arguments.CommandAndArguments[0]; string[] commandRawArguments = new string[Arguments.CommandAndArguments.Length - 1]; Array.Copy(Arguments.CommandAndArguments, 1, commandRawArguments, 0, commandRawArguments.Length); IUtilityCommand command = GetSpecialCommand(commandName); bool isSpecialCommand = command != null; var runtimeSetup = new RuntimeSetup(); GenericCollectionUtils.ForEach(Arguments.PluginDirectories, x => runtimeSetup.AddPluginDirectory(x)); using (isSpecialCommand ? null : RuntimeBootstrap.Initialize(runtimeSetup, logger)) { if (command == null) { var commandManager = RuntimeAccessor.ServiceLocator.Resolve <IUtilityCommandManager>(); command = commandManager.GetCommand(commandName); if (command == null) { ShowErrorMessage(string.Format("Unrecognized utility command name: '{0}'.", commandName)); ShowHelp(); return(1); } } Type commandArgumentsClass = command.GetArgumentClass(); var commandArgumentParser = new CommandLineArgumentParser(commandArgumentsClass, null); if (Arguments.Help) { ShowHelpForParticularCommand(commandName, commandArgumentParser); return(0); } object commandArguments = Activator.CreateInstance(commandArgumentsClass); if (!commandArgumentParser.Parse(commandRawArguments, commandArguments, ShowErrorMessage) || !command.ValidateArguments(commandArguments, ShowErrorMessage)) { ShowHelpForParticularCommand(commandName, commandArgumentParser); return(1); } var commandContext = new UtilityCommandContext(commandArguments, Console, logger, progressMonitorProvider, Arguments.Verbosity); return(command.Execute(commandContext)); } }