Skip to content

Commit

Permalink
(chocolateyGH-15)(config) set feature to configuration
Browse files Browse the repository at this point in the history
Require the feature and enabled to explicitly be set to true to allow a
feature to be flagged as on.
  • Loading branch information
ferventcoder committed Jan 18, 2015
1 parent d069daa commit 5f28b4e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/chocolatey/infrastructure.app/ApplicationParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -151,6 +152,11 @@ private void output_tostring(StringBuilder propertyValues, IEnumerable<PropertyI
/// </summary>
public InformationCommandConfiguration Information { get; private set; }

/// <summary>
/// Configuration related to features and whether they are enabled.
/// </summary>
public FeaturesConfiguration Features { get; private set; }

/// <summary>
/// Configuration related specifically to List command
/// </summary>
Expand All @@ -175,6 +181,7 @@ private void output_tostring(StringBuilder propertyValues, IEnumerable<PropertyI
/// Configuration related specifically to Push command
/// </summary>
public PushCommandConfiguration PushCommand { get; private set; }

}

public sealed class InformationCommandConfiguration
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
<source id="chocolatey" value="https://chocolatey.org/api/v2/" />
</sources>
<features>
<feature id="autouninstaller" enabled="false" />
<feature name="autouninstaller" enbabled="false" />
</features>
</chocolatey>

0 comments on commit 5f28b4e

Please sign in to comment.