public int RunModule( [Operand(Name = "module-name", Description = "The name of the module.")] string moduleName, [Option(LongName = "plugin")] List <string> pluginListOverride, [Option(LongName = "param", ShortName = "p")] List <string> moduleSettingOverrides) { var commandContext = CommandLineHandler.Context; if (string.IsNullOrEmpty(moduleName)) { CommandLineHandler.DisplayHelp("run module"); return((int)ExecutionResult.HostArgumentError); } commandContext.Logger.Information("loading module {Module}", moduleName); var loadResult = ModuleLoader.LoadModule(commandContext, moduleName, moduleSettingOverrides?.ToArray(), pluginListOverride?.ToArray(), false, out var module); if (loadResult != ExecutionResult.Success) { return((int)loadResult); } var executionResult = ExecutionResult.Success; if (module.EnabledPlugins.Count > 0) { executionResult = ModuleExecuter.Execute(commandContext, module); } ModuleLoader.UnloadModule(commandContext, module); return((int)executionResult); }
public int RunModules( [Operand(Name = "module-names", Description = "The space-separated list of module names.")] List <string> moduleNames, [Option(LongName = "param", ShortName = "p")] List <string> moduleSettingOverrides) { var commandContext = CommandLineHandler.Context; if (moduleNames == null || moduleNames.Count == 0) { CommandLineHandler.DisplayHelp("run modules"); return((int)ExecutionResult.HostArgumentError); } var modules = new List <Module>(); foreach (var moduleName in moduleNames) { commandContext.Logger.Information("loading module {Module}", moduleName); var loadResult = ModuleLoader.LoadModule(commandContext, moduleName, moduleSettingOverrides?.ToArray(), null, false, out var module); if (loadResult != ExecutionResult.Success) { return((int)loadResult); } if (module.EnabledPlugins?.Count == 0) { commandContext.Logger.Warning("skipping module {Module} due to it has no enabled plugins", moduleName); ModuleLoader.UnloadModule(commandContext, module); continue; } modules.Add(module); } var executionResult = ModuleExecuter.Execute(commandContext, modules.ToArray()); foreach (var module in modules) { ModuleLoader.UnloadModule(commandContext, module); } return((int)executionResult); }
public int ValidateModule( [Operand(Name = "names", Description = "The space-separated list of module names.")] List <string> moduleNames, [Option(LongName = "all", ShortName = "a")] bool all) { if (moduleNames == null || moduleNames.Count == 0) { if (!all) { CommandLineHandler.DisplayHelp("test modules"); return((int)ExecutionResult.HostArgumentError); } } else if (all) { CommandLineHandler.DisplayHelp("test modules"); return((int)ExecutionResult.HostArgumentError); } var commandContext = CommandLineHandler.Context; if (all) { moduleNames = ModuleLister.GetAllModules(commandContext); } foreach (var moduleName in moduleNames) { commandContext.Logger.Information("loading module {Module}", moduleName); ModuleLoader.LoadModule(commandContext, moduleName, null, null, true, out var module); if (module != null) { ModuleLoader.UnloadModule(commandContext, module); commandContext.Logger.Information("validation {ValidationResult} for {Module}", "PASSED", moduleName); } else { commandContext.Logger.Information("validation {ValidationResult} for {Module}", "FAILED", moduleName); } } return((int)ExecutionResult.Success); }