From c1d7ae59a9514ba9a09eadbf8a538411a9ec7b61 Mon Sep 17 00:00:00 2001 From: Luis Enrique Chacon Ochoa Date: Thu, 4 Mar 2021 16:50:06 -0800 Subject: [PATCH] Split Import/Export experimental feature setting --- doc/Settings.md | 6 +++--- schemas/JSON/settings/settings.schema.0.2.json | 6 +++--- src/AppInstallerCLICore/Commands/ExportCommand.h | 2 +- src/AppInstallerCLICore/Commands/ImportCommand.h | 2 +- src/AppInstallerCLIE2ETests/ImportCommand.cs | 3 ++- src/AppInstallerCommonCore/ExperimentalFeature.cpp | 12 ++++++++---- .../Public/winget/ExperimentalFeature.h | 8 ++++++-- .../Public/winget/UserSettings.h | 6 ++++-- src/AppInstallerCommonCore/UserSettings.cpp | 10 ++++++++-- 9 files changed, 36 insertions(+), 19 deletions(-) diff --git a/doc/Settings.md b/doc/Settings.md index 231ce7315c..fe084d0b64 100644 --- a/doc/Settings.md +++ b/doc/Settings.md @@ -98,12 +98,12 @@ While work is in progress on uninstall, the command is hidden behind a feature t }, ``` -### importExport +### import -While work is in progress for import and export, the command is hidden behind a feature toggle. One can enable it as below: +While work is in progress for import, the command is hidden behind a feature toggle. One can enable it as below: ``` "experimentalFeatures": { - "importExport": true + "import": true }, ``` diff --git a/schemas/JSON/settings/settings.schema.0.2.json b/schemas/JSON/settings/settings.schema.0.2.json index 16f43b6a02..086b534d66 100644 --- a/schemas/JSON/settings/settings.schema.0.2.json +++ b/schemas/JSON/settings/settings.schema.0.2.json @@ -63,15 +63,15 @@ "type": "boolean", "default": false }, - "importExport": { - "description": "Enable the import and export commands", + "import": { + "description": "Enable the import command while it is in development", "type": "boolean", "default": false } } } }, - "allOf": [ + "allOf": [ { "properties": { "visual": { "$ref": "#/definitions/Visual" } diff --git a/src/AppInstallerCLICore/Commands/ExportCommand.h b/src/AppInstallerCLICore/Commands/ExportCommand.h index 0c11977b4a..0dcbb8fcbe 100644 --- a/src/AppInstallerCLICore/Commands/ExportCommand.h +++ b/src/AppInstallerCLICore/Commands/ExportCommand.h @@ -8,7 +8,7 @@ namespace AppInstaller::CLI // Command to get the set of installed packages on the system. struct ExportCommand final : public Command { - ExportCommand(std::string_view parent) : Command("export", parent, Settings::ExperimentalFeature::Feature::ExperimentalImportExport) {} + ExportCommand(std::string_view parent) : Command("export", parent, Settings::ExperimentalFeature::Feature::ExperimentalExport) {} std::vector GetArguments() const override; diff --git a/src/AppInstallerCLICore/Commands/ImportCommand.h b/src/AppInstallerCLICore/Commands/ImportCommand.h index d2a58db14c..d9c75c3446 100644 --- a/src/AppInstallerCLICore/Commands/ImportCommand.h +++ b/src/AppInstallerCLICore/Commands/ImportCommand.h @@ -8,7 +8,7 @@ namespace AppInstaller::CLI // Command to install a set of packages from a list. struct ImportCommand final : public Command { - ImportCommand(std::string_view parent) : Command("import", parent, Settings::ExperimentalFeature::Feature::ExperimentalImportExport) {} + ImportCommand(std::string_view parent) : Command("import", parent, Settings::ExperimentalFeature::Feature::ExperimentalImport) {} std::vector GetArguments() const override; diff --git a/src/AppInstallerCLIE2ETests/ImportCommand.cs b/src/AppInstallerCLIE2ETests/ImportCommand.cs index 912c7cc083..966f09c612 100644 --- a/src/AppInstallerCLIE2ETests/ImportCommand.cs +++ b/src/AppInstallerCLIE2ETests/ImportCommand.cs @@ -12,7 +12,8 @@ public class ImportCommand : BaseCommand public void Setup() { InitializeAllFeatures(false); - ConfigureFeature("importExport", true); + ConfigureFeature("import", true); + ConfigureFeature("export", true); CleanupTestExe(); } diff --git a/src/AppInstallerCommonCore/ExperimentalFeature.cpp b/src/AppInstallerCommonCore/ExperimentalFeature.cpp index 55a8e93c41..185d9cfacb 100644 --- a/src/AppInstallerCommonCore/ExperimentalFeature.cpp +++ b/src/AppInstallerCommonCore/ExperimentalFeature.cpp @@ -27,8 +27,10 @@ namespace AppInstaller::Settings return User().Get(); case Feature::ExperimentalUninstall: return User().Get(); - case Feature::ExperimentalImportExport: - return User().Get(); + case Feature::ExperimentalImport: + return User().Get(); + case Feature::ExperimentalExport: + return User().Get(); default: THROW_HR(E_UNEXPECTED); } @@ -50,8 +52,10 @@ namespace AppInstaller::Settings return ExperimentalFeature{ "Upgrade Command", "upgrade", "https://aka.ms/winget-settings", Feature::ExperimentalUpgrade }; case Feature::ExperimentalUninstall: return ExperimentalFeature{ "Uninstall Command", "uninstall", "https://aka.ms/winget-settings", Feature::ExperimentalUninstall }; - case Feature::ExperimentalImportExport: - return ExperimentalFeature{ "Import & Export Commands", "importExport", "https://aka.ms/winget-settings", Feature::ExperimentalImportExport }; + case Feature::ExperimentalImport: + return ExperimentalFeature{ "Import Command", "import", "https://aka.ms/winget-settings", Feature::ExperimentalImport }; + case Feature::ExperimentalExport: + return ExperimentalFeature{ "Export Command", "export", "https://aka.ms/winget-settings", Feature::ExperimentalExport }; default: THROW_HR(E_UNEXPECTED); } diff --git a/src/AppInstallerCommonCore/Public/winget/ExperimentalFeature.h b/src/AppInstallerCommonCore/Public/winget/ExperimentalFeature.h index 2d09eea653..f58c2b1d90 100644 --- a/src/AppInstallerCommonCore/Public/winget/ExperimentalFeature.h +++ b/src/AppInstallerCommonCore/Public/winget/ExperimentalFeature.h @@ -25,8 +25,12 @@ namespace AppInstaller::Settings ExperimentalList = 0x8, ExperimentalUpgrade = 0x10, ExperimentalUninstall = 0x20, - ExperimentalImportExport = 0x40, - Max, // This MUST always be last + ExperimentalImport = 0x40, + Max, // This MUST always be after all experimental features + + // Features listed after Max will not be shown with the features command + // This can be used to hide highly experimental features + ExperimentalExport = 0x80 }; using Feature_t = std::underlying_type_t; diff --git a/src/AppInstallerCommonCore/Public/winget/UserSettings.h b/src/AppInstallerCommonCore/Public/winget/UserSettings.h index 3b33c4d9fe..37a9230a61 100644 --- a/src/AppInstallerCommonCore/Public/winget/UserSettings.h +++ b/src/AppInstallerCommonCore/Public/winget/UserSettings.h @@ -52,7 +52,8 @@ namespace AppInstaller::Settings EFList, EFExperimentalUpgrade, EFUninstall, - EFImportExport, + EFImport, + EFExport, Max }; @@ -88,7 +89,8 @@ namespace AppInstaller::Settings SETTINGMAPPING_SPECIALIZATION(Setting::EFList, bool, bool, false, ".experimentalFeatures.list"sv); SETTINGMAPPING_SPECIALIZATION(Setting::EFExperimentalUpgrade, bool, bool, false, ".experimentalFeatures.upgrade"sv); SETTINGMAPPING_SPECIALIZATION(Setting::EFUninstall, bool, bool, false, ".experimentalFeatures.uninstall"sv); - SETTINGMAPPING_SPECIALIZATION(Setting::EFImportExport, bool, bool, false, ".experimentalFeatures.importExport"sv); + SETTINGMAPPING_SPECIALIZATION(Setting::EFImport, bool, bool, false, ".experimentalFeatures.import"sv); + SETTINGMAPPING_SPECIALIZATION(Setting::EFExport, bool, bool, false, ".experimentalFeatures.export"sv); // Used to deduce the SettingVariant type; making a variant that includes std::monostate and all SettingMapping types. template diff --git a/src/AppInstallerCommonCore/UserSettings.cpp b/src/AppInstallerCommonCore/UserSettings.cpp index d9d1308d0c..260bb8ad24 100644 --- a/src/AppInstallerCommonCore/UserSettings.cpp +++ b/src/AppInstallerCommonCore/UserSettings.cpp @@ -217,8 +217,14 @@ namespace AppInstaller::Settings return value; } - std::optional::value_t> - SettingMapping::Validate(const SettingMapping::json_t& value) + std::optional::value_t> + SettingMapping::Validate(const SettingMapping::json_t& value) + { + return value; + } + + std::optional::value_t> + SettingMapping::Validate(const SettingMapping::json_t& value) { return value; }