From 0450b80d45d0f26554d591c0d8b561cc9d169b63 Mon Sep 17 00:00:00 2001 From: Kaleb Luedtke Date: Wed, 28 Feb 2024 22:19:38 -0600 Subject: [PATCH 1/2] Add --ignore-warnings to Export command --- src/AppInstallerCLICore/Commands/ExportCommand.cpp | 1 + src/AppInstallerCLICore/Workflows/ImportExportFlow.cpp | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/AppInstallerCLICore/Commands/ExportCommand.cpp b/src/AppInstallerCLICore/Commands/ExportCommand.cpp index 8b1ba8c690..7927d01289 100644 --- a/src/AppInstallerCLICore/Commands/ExportCommand.cpp +++ b/src/AppInstallerCLICore/Commands/ExportCommand.cpp @@ -19,6 +19,7 @@ namespace AppInstaller::CLI Argument{ Execution::Args::Type::Source, Resource::String::ExportSourceArgumentDescription, ArgumentType::Standard }, Argument{ Execution::Args::Type::IncludeVersions, Resource::String::ExportIncludeVersionsArgumentDescription, ArgumentType::Flag }, Argument::ForType(Execution::Args::Type::AcceptSourceAgreements), + Argument::ForType(Execution::Args::Type::IgnoreWarnings), }; } diff --git a/src/AppInstallerCLICore/Workflows/ImportExportFlow.cpp b/src/AppInstallerCLICore/Workflows/ImportExportFlow.cpp index 06c87eb73e..ff8b775a85 100644 --- a/src/AppInstallerCLICore/Workflows/ImportExportFlow.cpp +++ b/src/AppInstallerCLICore/Workflows/ImportExportFlow.cpp @@ -98,6 +98,7 @@ namespace AppInstaller::CLI::Workflow { const auto& searchResult = context.Get(); const bool includeVersions = context.Args.Contains(Execution::Args::Type::IncludeVersions); + const bool suppressWarnings = context.Args.Contains(Execution::Args::Type::IgnoreWarnings); PackageCollection exportedPackages; exportedPackages.ClientVersion = Runtime::GetClientVersion().get(); auto& exportedSources = exportedPackages.Sources; @@ -113,7 +114,9 @@ namespace AppInstaller::CLI::Workflow { // Report package not found and move to next package. AICLI_LOG(CLI, Warning, << "No available version of package [" << installedPackageVersion->GetProperty(PackageVersionProperty::Name) << "] was found to export"); - context.Reporter.Warn() << Resource::String::InstalledPackageNotAvailable(installedPackageVersion->GetProperty(PackageVersionProperty::Name)) << std::endl; + if (!suppressWarnings) { + context.Reporter.Warn() << Resource::String::InstalledPackageNotAvailable(installedPackageVersion->GetProperty(PackageVersionProperty::Name)) << std::endl; + } continue; } @@ -125,7 +128,9 @@ namespace AppInstaller::CLI::Workflow { // Report that the package requires accepting license terms AICLI_LOG(CLI, Warning, << "Package [" << installedPackageVersion->GetProperty(PackageVersionProperty::Name) << "] requires license agreement to install"); - context.Reporter.Warn() << Resource::String::ExportedPackageRequiresLicenseAgreement(installedPackageVersion->GetProperty(PackageVersionProperty::Name)) << std::endl; + if (!suppressWarnings) { + context.Reporter.Warn() << Resource::String::ExportedPackageRequiresLicenseAgreement(installedPackageVersion->GetProperty(PackageVersionProperty::Name)) << std::endl; + } } // Find the exported source for this package From a994052d750996e2711efe4b9e63b2856aa16d5f Mon Sep 17 00:00:00 2001 From: Kaleb Luedtke Date: Wed, 28 Feb 2024 22:37:11 -0600 Subject: [PATCH 2/2] Missed one --- src/AppInstallerCLICore/Workflows/ImportExportFlow.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/AppInstallerCLICore/Workflows/ImportExportFlow.cpp b/src/AppInstallerCLICore/Workflows/ImportExportFlow.cpp index ff8b775a85..f0c9e2a67e 100644 --- a/src/AppInstallerCLICore/Workflows/ImportExportFlow.cpp +++ b/src/AppInstallerCLICore/Workflows/ImportExportFlow.cpp @@ -67,6 +67,7 @@ namespace AppInstaller::CLI::Workflow bool checkVersion) { std::shared_ptr availableVersions = GetAvailableVersionsForInstalledVersion(package); + const bool suppressWarnings = context.Args.Contains(Execution::Args::Type::IgnoreWarnings); if (!checkVersion) { @@ -86,7 +87,9 @@ namespace AppInstaller::CLI::Workflow << "Installed package version is not available." << " Package Id [" << availablePackageVersion->GetProperty(PackageVersionProperty::Id) << "], Version [" << version << "], Channel [" << channel << "]" << ". Found Version [" << availablePackageVersion->GetProperty(PackageVersionProperty::Version) << "], Channel [" << availablePackageVersion->GetProperty(PackageVersionProperty::Version) << "]"); - context.Reporter.Warn() << Resource::String::InstalledPackageVersionNotAvailable(availablePackageVersion->GetProperty(PackageVersionProperty::Id), version, channel) << std::endl; + if (!suppressWarnings) { + context.Reporter.Warn() << Resource::String::InstalledPackageVersionNotAvailable(availablePackageVersion->GetProperty(PackageVersionProperty::Id), version, channel) << std::endl; + } } } @@ -238,7 +241,7 @@ namespace AppInstaller::CLI::Workflow else { AICLI_LOG(CLI, Error, << "Missing required source: " << requiredSource.Details.Name); - context.Reporter.Warn() + context.Reporter.Error() << Resource::String::ImportSourceNotInstalled(Utility::LocIndView{ requiredSource.Details.Name }) << std::endl; AICLI_TERMINATE_CONTEXT(APPINSTALLER_CLI_ERROR_SOURCE_NAME_DOES_NOT_EXIST);