protected override async Task <NewCommandStatus> ExecuteAsync( SearchCommandArgs args, IEngineEnvironmentSettings environmentSettings, ITelemetryLogger telemetryLogger, InvocationContext context) { using TemplatePackageManager templatePackageManager = new TemplatePackageManager(environmentSettings); //we need to await, otherwise templatePackageManager will be disposed. return(await CliTemplateSearchCoordinator.SearchForTemplateMatchesAsync( environmentSettings, templatePackageManager, args, environmentSettings.GetDefaultLanguage(), context.GetCancellationToken()).ConfigureAwait(false)); }
private async Task <CreationResultStatus> ExecuteAsync() { // this is checking the initial parse, which is template agnostic. if (_commandInput.HasParseError) { return(HelpForTemplateResolution.HandleParseError(_commandInput, _telemetryLogger)); } if (_commandInput.IsHelpFlagSpecified) { _telemetryLogger.TrackEvent(CommandName + TelemetryConstants.HelpEventSuffix); } if (_commandInput.ShowAliasesSpecified) { return(AliasSupport.DisplayAliasValues(EnvironmentSettings, _commandInput, _aliasRegistry, CommandName)); } if (_commandInput.ExpandedExtraArgsFiles && string.IsNullOrEmpty(_commandInput.Alias)) { // Only show this if there was no alias expansion. // ExpandedExtraArgsFiles must be checked before alias expansion - it'll get reset if there's an alias. Reporter.Output.WriteLine(string.Format(LocalizableStrings.ExtraArgsCommandAfterExpansion, string.Join(" ", _commandInput.Tokens))); } if (string.IsNullOrEmpty(_commandInput.Alias)) { // The --alias param is for creating / updating / deleting aliases. // If it's not present, try expanding aliases now. CreationResultStatus aliasExpansionResult = AliasSupport.CoordinateAliasExpansion(_commandInput, _aliasRegistry, _telemetryLogger); if (aliasExpansionResult != CreationResultStatus.Success) { return(aliasExpansionResult); } } if (!ConfigureLocale()) { return(CreationResultStatus.InvalidParamValues); } if (!Initialize()) { return(CreationResultStatus.Success); } try { bool isHiveUpdated = SyncOptionalWorkloads(); if (isHiveUpdated) { Reporter.Output.WriteLine(LocalizableStrings.OptionalWorkloadsSynchronized); } } catch (HiveSynchronizationException hiex) { Reporter.Error.WriteLine(hiex.Message.Bold().Red()); } bool forceCacheRebuild = _commandInput.HasDebuggingFlag("--debug:rebuildcache"); try { _settingsLoader.RebuildCacheFromSettingsIfNotCurrent(forceCacheRebuild); } catch (EngineInitializationException eiex) { Reporter.Error.WriteLine(eiex.Message.Bold().Red()); Reporter.Error.WriteLine(LocalizableStrings.SettingsReadError); return(CreationResultStatus.CreateFailed); } try { if (!string.IsNullOrEmpty(_commandInput.Alias) && !_commandInput.IsHelpFlagSpecified) { return(AliasSupport.ManipulateAliasIfValid(_aliasRegistry, _commandInput.Alias, _commandInput.Tokens.ToList(), AllTemplateShortNames)); } if (_commandInput.CheckForUpdates || _commandInput.CheckForUpdatesNoPrompt) { bool applyUpdates = _commandInput.CheckForUpdatesNoPrompt; CliTemplateUpdater updater = new CliTemplateUpdater(EnvironmentSettings, Installer, CommandName); bool updateCheckResult = await updater.CheckForUpdatesAsync(_settingsLoader.InstallUnitDescriptorCache.Descriptors.Values.ToList(), applyUpdates); return(updateCheckResult ? CreationResultStatus.Success : CreationResultStatus.CreateFailed); } if (_commandInput.SearchOnline) { return(await CliTemplateSearchCoordinator.SearchForTemplateMatchesAsync(EnvironmentSettings, _commandInput, _defaultLanguage).ConfigureAwait(false)); } if (string.IsNullOrWhiteSpace(TemplateName)) { return(EnterMaintenanceFlow()); } return(await EnterTemplateManipulationFlowAsync().ConfigureAwait(false)); } catch (TemplateAuthoringException tae) { Reporter.Error.WriteLine(tae.Message.Bold().Red()); return(CreationResultStatus.CreateFailed); } }