internal PostActionDispatcher(IEngineEnvironmentSettings environment, New3Callbacks callbacks, TemplateCreationResult creationResult, AllowPostActionsSetting canRunStatus, bool isDryRun) { _environment = environment; _callbacks = callbacks; _creationResult = creationResult; _canRunScripts = canRunStatus; _isDryRun = isDryRun; }
internal TemplateInvocationCoordinator(ISettingsLoader settingsLoader, INewCommandInput commandInput, ITelemetryLogger telemetryLogger, string commandName, Func <string> inputGetter, New3Callbacks callbacks) { _settingsLoader = settingsLoader; _environment = _settingsLoader.EnvironmentSettings; _commandInput = commandInput; _telemetryLogger = telemetryLogger; _commandName = commandName; _inputGetter = inputGetter; _callbacks = callbacks; }
public TemplateInvoker(IEngineEnvironmentSettings environment, INewCommandInput commandInput, ITelemetryLogger telemetryLogger, string commandName, Func <string> inputGetter, New3Callbacks callbacks) { _environment = environment; _commandInput = commandInput; _telemetryLogger = telemetryLogger; _commandName = commandName; _inputGetter = inputGetter; _callbacks = callbacks; _templateCreator = new TemplateCreator(_environment); _hostDataLoader = new HostSpecificDataLoader(_environment.SettingsLoader); }
public TemplateInvocationAndAcquisitionCoordinator(SettingsLoader settingsLoader, INewCommandInput commandInput, TemplateCreator templateCreator, IHostSpecificDataLoader hostDataLoader, ITelemetryLogger telemetryLogger, string defaultLanguage, string commandName, Func <string> inputGetter, New3Callbacks callbacks) { _settingsLoader = settingsLoader; _environment = _settingsLoader.EnvironmentSettings; _commandInput = commandInput; _templateCreator = templateCreator; _hostDataLoader = hostDataLoader; _telemetryLogger = telemetryLogger; _defaultLanguage = defaultLanguage; _commandName = commandName; _inputGetter = inputGetter; _callbacks = callbacks; }
internal New3Command(string commandName, ITemplateEngineHost host, ITelemetryLogger telemetryLogger, New3Callbacks callbacks, INewCommandInput commandInput, string?hivePath, bool virtualize = false) { _telemetryLogger = telemetryLogger; host = new ExtendedTemplateEngineHost(host, this); EnvironmentSettings = new EngineEnvironmentSettings(host, settingsLocation: hivePath, onFirstRun: FirstRun, virtualizeSettings: virtualize); _settingsLoader = EnvironmentSettings.SettingsLoader; _templateCreator = new TemplateCreator(EnvironmentSettings); _aliasRegistry = new AliasRegistry(EnvironmentSettings); CommandName = commandName; _hostDataLoader = new HostSpecificDataLoader(EnvironmentSettings.SettingsLoader); _commandInput = commandInput; _callbacks = callbacks; if (callbacks == null) { callbacks = new New3Callbacks(); } if (!EnvironmentSettings.Host.TryGetHostParamDefault("prefs:language", out _defaultLanguage)) { _defaultLanguage = null; } }
public New3Command(string commandName, ITemplateEngineHost host, ITelemetryLogger telemetryLogger, New3Callbacks callbacks, INewCommandInput commandInput, string hivePath) { _telemetryLogger = telemetryLogger; host = new ExtendedTemplateEngineHost(host, this); EnvironmentSettings = new EngineEnvironmentSettings(host, x => new SettingsLoader(x), hivePath); _settingsLoader = (SettingsLoader)EnvironmentSettings.SettingsLoader; Installer = new Installer(EnvironmentSettings); _templateCreator = new TemplateCreator(EnvironmentSettings); _aliasRegistry = new AliasRegistry(EnvironmentSettings); CommandName = commandName; _paths = new Paths(EnvironmentSettings); _hostDataLoader = new HostSpecificDataLoader(EnvironmentSettings.SettingsLoader); _commandInput = commandInput; _callbacks = callbacks; if (callbacks == null) { callbacks = new New3Callbacks(); } if (!EnvironmentSettings.Host.TryGetHostParamDefault("prefs:language", out _defaultLanguage)) { _defaultLanguage = null; } }
public New3Command(string commandName, ITemplateEngineHost host, ITelemetryLogger telemetryLogger, New3Callbacks callbacks, INewCommandInput commandInput) : this(commandName, host, telemetryLogger, callbacks, commandInput, null) { }
private static int ActualRun(string commandName, ITemplateEngineHost host, ITelemetryLogger telemetryLogger, New3Callbacks callbacks, string[] args, string hivePath) { if (args.Any(x => string.Equals(x, "--debug:version", StringComparison.Ordinal))) { ShowVersion(); return(0); } if (args.Any(x => string.Equals(x, "--debug:attach", StringComparison.Ordinal))) { Console.ReadLine(); } int customHiveFlagIndex = args.ToList().IndexOf("--debug:custom-hive"); if (customHiveFlagIndex >= 0) { if (customHiveFlagIndex + 1 >= args.Length) { Reporter.Error.WriteLine("--debug:custom-hive requires 1 arg indicating the absolute or relative path to the custom hive".Bold().Red()); return(1); } hivePath = args[customHiveFlagIndex + 1]; if (hivePath.StartsWith("-")) { Reporter.Error.WriteLine("--debug:custom-hive requires 1 arg indicating the absolute or relative path to the custom hive".Bold().Red()); return(1); } } if (args.Length == 0) { telemetryLogger.TrackEvent(commandName + TelemetryConstants.CalledWithNoArgsEventSuffix); } INewCommandInput commandInput = new NewCommandInputCli(commandName); New3Command instance = new New3Command(commandName, host, telemetryLogger, callbacks, commandInput, hivePath); commandInput.OnExecute(instance.ExecuteAsync); int result; try { using (Timing.Over(host, "Execute")) { result = commandInput.Execute(args); } } catch (Exception ex) { AggregateException ax = ex as AggregateException; while (ax != null && ax.InnerExceptions.Count == 1) { ex = ax.InnerException; ax = ex as AggregateException; } Reporter.Error.WriteLine(ex.Message.Bold().Red()); while (ex.InnerException != null) { ex = ex.InnerException; ax = ex as AggregateException; while (ax != null && ax.InnerExceptions.Count == 1) { ex = ax.InnerException; ax = ex as AggregateException; } Reporter.Error.WriteLine(ex.Message.Bold().Red()); } Reporter.Error.WriteLine(ex.StackTrace.Bold().Red()); result = 1; } return(result); }
public static int Run(string commandName, ITemplateEngineHost host, ITelemetryLogger telemetryLogger, New3Callbacks callbacks, string[] args, string hivePath) { if (!args.Any(x => string.Equals(x, "--debug:ephemeral-hive"))) { EnsureEntryMutex(hivePath, host); if (!_entryMutex.WaitOne()) { return(-1); } } try { return(ActualRun(commandName, host, telemetryLogger, callbacks, args, hivePath)); } finally { if (_entryMutex != null) { _entryMutex.ReleaseMutex(); } } }
public static int Run(string commandName, ITemplateEngineHost host, ITelemetryLogger telemetryLogger, New3Callbacks callbacks, string[] args, string?hivePath = null) { _ = host ?? throw new ArgumentNullException(nameof(host)); _ = telemetryLogger ?? throw new ArgumentNullException(nameof(telemetryLogger)); _ = callbacks ?? throw new ArgumentNullException(nameof(callbacks)); _ = args ?? throw new ArgumentNullException(nameof(args)); if (!args.Any(x => string.Equals(x, "--debug:ephemeral-hive"))) { EnsureEntryMutex(hivePath, host); if (!_entryMutex !.WaitOne()) { return(-1); } } try { return(ActualRun(commandName, host, telemetryLogger, callbacks, args, hivePath)); } finally { if (_entryMutex != null) { _entryMutex.ReleaseMutex(); } } }