Beispiel #1
0
 public static TBootstrapper AddPipelineCommand <TBootstrapper>(
     this TBootstrapper bootstrapper,
     string name,
     string description,
     EngineCommandSettings commandSettings)
     where TBootstrapper : IBootstrapper =>
 bootstrapper.ConfigureCommands(x => x.AddPipelineCommand(name, commandSettings).WithDescription(description));
Beispiel #2
0
        public EngineManager(
            CommandContext commandContext,
            EngineCommandSettings commandSettings,
            IConfigurationSettings configurationSettings,
            IServiceCollection serviceCollection,
            Bootstrapper bootstrapper)
        {
            // Get the standard input stream
            string input = null;

            if (commandSettings?.StdIn == true)
            {
                using (StreamReader reader = new StreamReader(Console.OpenStandardInput(), Console.InputEncoding))
                {
                    input = reader.ReadToEnd();
                }
            }

            // Create the application state
            ApplicationState applicationState = new ApplicationState(bootstrapper.Arguments, commandContext.Name, input);

            // Create the engine and get a logger
            // The configuration settings should not be used after this point
            ConfigurationSettings        configurationSettingsImpl = configurationSettings as ConfigurationSettings;
            IDictionary <string, object> settings = configurationSettingsImpl?.Settings;

            Engine = new Engine(applicationState, serviceCollection, configurationSettings.Configuration, settings, bootstrapper.ClassCatalog);
            configurationSettingsImpl?.Dispose();

            // Get the logger from the engine and store it for use during execute
            _logger = Engine.Services.GetRequiredService <ILogger <Bootstrapper> >();

            // Apply command settings
            if (commandSettings != null)
            {
                ApplyCommandSettings(Engine, commandSettings);
            }

            // Run engine configurators after command line, settings, etc. have been applied
            bootstrapper.Configurators.Configure <IEngine>(Engine);

            // Log the full environment
            _logger.LogInformation($"Root path:{Environment.NewLine}       {Engine.FileSystem.RootPath}");
            _logger.LogInformation($"Input path(s):{Environment.NewLine}       {string.Join(Environment.NewLine + "       ", Engine.FileSystem.InputPaths)}");
            _logger.LogInformation($"Output path:{Environment.NewLine}       {Engine.FileSystem.OutputPath}");
            _logger.LogInformation($"Temp path:{Environment.NewLine}       {Engine.FileSystem.TempPath}");
        }
Beispiel #3
0
        public EngineManager(
            CommandContext commandContext,
            EngineCommandSettings commandSettings,
            IConfigurationSettings configurationSettings,
            IConfigurationRoot configurationRoot,
            IServiceCollection serviceCollection,
            IBootstrapper bootstrapper)
        {
            // Get the standard input stream
            string input = null;

            if (commandSettings?.StdIn == true)
            {
                using (StreamReader reader = new StreamReader(Console.OpenStandardInput(), Console.InputEncoding))
                {
                    input = reader.ReadToEnd();
                }
            }

            // Create the application state
            ApplicationState applicationState = new ApplicationState(bootstrapper.Arguments, commandContext.Name, input);

            // Create the engine and get a logger
            Engine  = new Engine(applicationState, configurationRoot, serviceCollection);
            _logger = Engine.Services.GetRequiredService <ILogger <Bootstrapper> >();

            // Apply command settings
            if (commandSettings != null)
            {
                ApplyCommandSettings(Engine, configurationSettings, commandSettings);
            }
            _pipelines        = commandSettings?.Pipelines;
            _defaultPipelines = commandSettings == null || commandSettings.Pipelines == null || commandSettings.Pipelines.Length == 0 || commandSettings.DefaultPipelines;

            // Run engine configurators after command line, settings, etc. have been applied
            bootstrapper.Configurators.Configure <IEngine>(Engine);

            // Log the full environment
            _logger.LogInformation($"Root path:{Environment.NewLine}       {Engine.FileSystem.RootPath}");
            _logger.LogInformation($"Input path(s):{Environment.NewLine}       {string.Join(Environment.NewLine + "       ", Engine.FileSystem.InputPaths)}");
            _logger.LogInformation($"Output path:{Environment.NewLine}       {Engine.FileSystem.OutputPath}");
            _logger.LogInformation($"Temp path:{Environment.NewLine}       {Engine.FileSystem.TempPath}");
        }
Beispiel #4
0
        private static void ApplyCommandSettings(Engine engine, EngineCommandSettings commandSettings)
        {
            // Set folders
            NormalizedPath currentDirectory = Environment.CurrentDirectory;

            engine.FileSystem.RootPath = string.IsNullOrEmpty(commandSettings.RootPath)
                ? currentDirectory
                : currentDirectory.Combine(commandSettings.RootPath);
            if (commandSettings.InputPaths?.Length > 0)
            {
                // Clear existing default paths if new ones are set
                // and reverse the inputs so the last one is first to match the semantics of multiple occurrence single options
                engine.FileSystem.InputPaths.Clear();
                engine.FileSystem.InputPaths.AddRange(commandSettings.InputPaths.Select(x => new NormalizedPath(x)).Reverse());
            }
            if (!string.IsNullOrEmpty(commandSettings.OutputPath))
            {
                engine.FileSystem.OutputPath = commandSettings.OutputPath;
            }
            if (commandSettings.NoClean)
            {
                engine.Settings[Keys.CleanOutputPath] = false;
            }

            // Set no cache if requested
            if (commandSettings.NoCache)
            {
                engine.Settings[Keys.UseCache] = false;
            }

            // Set serial mode
            if (commandSettings.SerialExecution)
            {
                engine.SerialExecution = true;
            }
        }
 public static Bootstrapper AddPipelineCommand(
     this Bootstrapper bootstrapper,
     string name,
     EngineCommandSettings commandSettings) =>
 bootstrapper.ConfigureCommands(x => x.AddPipelineCommand(name, commandSettings));
        private static void ApplyCommandSettings(Engine engine, IDictionary <string, string> settings, EngineCommandSettings commandSettings)
        {
            // Set folders
            DirectoryPath currentDirectory = Environment.CurrentDirectory;

            engine.FileSystem.RootPath = string.IsNullOrEmpty(commandSettings.RootPath)
                ? currentDirectory
                : currentDirectory.Combine(commandSettings.RootPath);
            if (commandSettings.InputPaths?.Length > 0)
            {
                // Clear existing default paths if new ones are set
                // and reverse the inputs so the last one is first to match the semantics of multiple occurrence single options
                engine.FileSystem.InputPaths.Clear();
                engine.FileSystem.InputPaths.AddRange(commandSettings.InputPaths.Select(x => new DirectoryPath(x)).Reverse());
            }
            if (!string.IsNullOrEmpty(commandSettings.OutputPath))
            {
                engine.FileSystem.OutputPath = commandSettings.OutputPath;
            }
            if (commandSettings.NoClean)
            {
                settings[Keys.CleanOutputPath] = "false";
            }

            // Set no cache if requested
            if (commandSettings.NoCache)
            {
                settings[Keys.UseCache] = "false";
            }

            // Set serial mode
            if (commandSettings.SerialExecution)
            {
                engine.SerialExecution = true;
            }

            // Add settings
            if (commandSettings.MetadataSettings?.Length > 0)
            {
                foreach (KeyValuePair <string, string> setting in MetadataParser.Parse(commandSettings.MetadataSettings))
                {
                    settings[setting.Key] = setting.Value;
                }
            }
        }