From 5f28b4e13f131521ae28fc0f084b5bed39c9b6c2 Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Sun, 18 Jan 2015 16:52:51 -0600 Subject: [PATCH] (GH-15)(config) set feature to configuration Require the feature and enabled to explicitly be set to true to allow a feature to be flagged as on. --- .../infrastructure.app/ApplicationParameters.cs | 5 +++++ .../builders/ConfigurationBuilder.cs | 5 +++++ .../configuration/ChocolateyConfiguration.cs | 12 ++++++++++++ .../configuration/ConfigFileFeatureSetting.cs | 4 ++-- .../configuration/chocolatey.config | 2 +- 5 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/chocolatey/infrastructure.app/ApplicationParameters.cs b/src/chocolatey/infrastructure.app/ApplicationParameters.cs index 45e6a56f06..2aab742af0 100644 --- a/src/chocolatey/infrastructure.app/ApplicationParameters.cs +++ b/src/chocolatey/infrastructure.app/ApplicationParameters.cs @@ -59,6 +59,11 @@ public static class Tools public static readonly string ShimGenExe = _fileSystem.combine_paths(InstallLocation, "tools", "shimgen.exe"); } + public static class Features + { + public static readonly string AutoUnintaller = "autouninstaller"; + } + public static class Messages { public static readonly string ContinueChocolateyAction = "Moving forward with chocolatey actions."; diff --git a/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs b/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs index 50391bf890..4cedb2e9e5 100644 --- a/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs +++ b/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs @@ -89,6 +89,11 @@ private static void set_file_configuration(ChocolateyConfiguration config, IFile } config.CommandExecutionTimeoutSeconds = configFileSettings.CommandExecutionTimeoutSeconds; + //refactor - as features grows, it will need it's own section. + config.Features.AutoUninstaller = false; + var feature = configFileSettings.Features.FirstOrDefault(f => f.Name.is_equal_to(ApplicationParameters.Features.AutoUnintaller)); + if (feature != null && feature.Enabled) config.Features.AutoUninstaller = true; + try { xmlService.serialize(configFileSettings, globalConfigPath); diff --git a/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs b/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs index 1c007b9c4e..cfc48861ff 100644 --- a/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs +++ b/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs @@ -32,6 +32,7 @@ public ChocolateyConfiguration() RegularOuptut = true; PromptForConfirmation = true; Information = new InformationCommandConfiguration(); + Features = new FeaturesConfiguration(); NewCommand = new NewCommandConfiguration(); ListCommand = new ListCommandConfiguration(); SourceCommand = new SourcesCommandConfiguration(); @@ -151,6 +152,11 @@ private void output_tostring(StringBuilder propertyValues, IEnumerable public InformationCommandConfiguration Information { get; private set; } + /// + /// Configuration related to features and whether they are enabled. + /// + public FeaturesConfiguration Features { get; private set; } + /// /// Configuration related specifically to List command /// @@ -175,6 +181,7 @@ private void output_tostring(StringBuilder propertyValues, IEnumerable public PushCommandConfiguration PushCommand { get; private set; } + } public sealed class InformationCommandConfiguration @@ -187,6 +194,11 @@ public sealed class InformationCommandConfiguration public bool IsInteractive { get; set; } } + public sealed class FeaturesConfiguration + { + public bool AutoUninstaller { get; set; } + } + //todo: retrofit other command configs this way public sealed class ListCommandConfiguration diff --git a/src/chocolatey/infrastructure.app/configuration/ConfigFileFeatureSetting.cs b/src/chocolatey/infrastructure.app/configuration/ConfigFileFeatureSetting.cs index 58dda483db..f1ad665537 100644 --- a/src/chocolatey/infrastructure.app/configuration/ConfigFileFeatureSetting.cs +++ b/src/chocolatey/infrastructure.app/configuration/ConfigFileFeatureSetting.cs @@ -25,8 +25,8 @@ namespace chocolatey.infrastructure.app.configuration [XmlType("feature")] public sealed class ConfigFileFeatureSetting { - [XmlAttribute(AttributeName = "id")] - public string Id { get; set; } + [XmlAttribute(AttributeName = "name")] + public string Name { get; set; } [XmlAttribute(AttributeName = "enabled")] public bool Enabled { get; set; } diff --git a/src/chocolatey/infrastructure.app/configuration/chocolatey.config b/src/chocolatey/infrastructure.app/configuration/chocolatey.config index e073fa95ca..53976f3642 100644 --- a/src/chocolatey/infrastructure.app/configuration/chocolatey.config +++ b/src/chocolatey/infrastructure.app/configuration/chocolatey.config @@ -9,6 +9,6 @@ - + \ No newline at end of file