Skip to content

Commit

Permalink
(GH-604) Source Operations Should Respect Quiet
Browse files Browse the repository at this point in the history
Any operations on sources should respect Quiet. This also corrects a
bug that was introduced by GH-132 in
8364b0e that removed output
information that is needed for tools that use choco. That has never
been introduced as a released version, so thankfully the bug doesn't
need to be worked around in any tools.
  • Loading branch information
ferventcoder committed Feb 4, 2016
1 parent 4020dfc commit 978fab9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/chocolatey.console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ private static void add_or_remove_licensed_source(ChocolateyLicense license, Con
var addOrUpdate = license.IsValid;
var config = new ChocolateyConfiguration {
RegularOutput = false,
QuietOutput = true,
};

var sourceService = container.GetInstance<IChocolateyConfigSettingsService>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace chocolatey.infrastructure.app.services
using System.Collections.Generic;
using System.Linq;
using configuration;
using infrastructure.configuration;
using infrastructure.services;
using logging;
using nuget;
Expand Down Expand Up @@ -50,7 +51,7 @@ public IEnumerable<ChocolateySource> source_list(ChocolateyConfiguration configu
var list = new List<ChocolateySource>();
foreach (var source in configFileSettings.Sources)
{
if (configuration.RegularOutput) {
if (!configuration.QuietOutput) {
this.Log().Info(() => "{0}{1} - {2} {3}| Priority {4}.".format_with(
source.Id,
source.Disabled ? " [Disabled]" : string.Empty,
Expand Down Expand Up @@ -85,7 +86,7 @@ public void source_add(ChocolateyConfiguration configuration)
configFileSettings.Sources.Add(source);

_xmlService.serialize(configFileSettings, ApplicationParameters.GlobalConfigFileLocation);
this.Log().Warn(() => "Added {0} - {1} (Priority {2})".format_with(source.Id, source.Value, source.Priority));
if (!configuration.QuietOutput) this.Log().Warn(() => "Added {0} - {1} (Priority {2})".format_with(source.Id, source.Value, source.Priority));
}
else
{
Expand All @@ -96,7 +97,7 @@ public void source_add(ChocolateyConfiguration configuration)
configuration.SourceCommand.Password.is_equal_to(currentPassword)
)
{
this.Log().Warn(NO_CHANGE_MESSAGE);
if (!configuration.QuietOutput) this.Log().Warn(NO_CHANGE_MESSAGE);
}
else
{
Expand All @@ -106,7 +107,7 @@ public void source_add(ChocolateyConfiguration configuration)
source.Password = NugetEncryptionUtility.EncryptString(configuration.SourceCommand.Password);

_xmlService.serialize(configFileSettings, ApplicationParameters.GlobalConfigFileLocation);
this.Log().Warn(() => "Updated {0} - {1} (Priority {2})".format_with(source.Id, source.Value, source.Priority));
if (!configuration.QuietOutput) this.Log().Warn(() => "Updated {0} - {1} (Priority {2})".format_with(source.Id, source.Value, source.Priority));
}
}
}
Expand All @@ -119,11 +120,11 @@ public void source_remove(ChocolateyConfiguration configuration)
configFileSettings.Sources.Remove(source);
_xmlService.serialize(configFileSettings, ApplicationParameters.GlobalConfigFileLocation);

this.Log().Warn(() => "Removed {0}".format_with(source.Id));
if (!configuration.QuietOutput) this.Log().Warn(() => "Removed {0}".format_with(source.Id));
}
else
{
this.Log().Warn(NO_CHANGE_MESSAGE);
if (!configuration.QuietOutput) this.Log().Warn(NO_CHANGE_MESSAGE);
}
}

Expand All @@ -134,11 +135,11 @@ public void source_disable(ChocolateyConfiguration configuration)
{
source.Disabled = true;
_xmlService.serialize(configFileSettings, ApplicationParameters.GlobalConfigFileLocation);
this.Log().Warn(() => "Disabled {0}".format_with(source.Id));
if (!configuration.QuietOutput) this.Log().Warn(() => "Disabled {0}".format_with(source.Id));
}
else
{
this.Log().Warn(NO_CHANGE_MESSAGE);
if (!configuration.QuietOutput) this.Log().Warn(NO_CHANGE_MESSAGE);
}
}

Expand All @@ -149,11 +150,11 @@ public void source_enable(ChocolateyConfiguration configuration)
{
source.Disabled = false;
_xmlService.serialize(configFileSettings, ApplicationParameters.GlobalConfigFileLocation);
this.Log().Warn(() => "Enabled {0}".format_with(source.Id));
if (!configuration.QuietOutput) this.Log().Warn(() => "Enabled {0}".format_with(source.Id));
}
else
{
this.Log().Warn(NO_CHANGE_MESSAGE);
if (!configuration.QuietOutput) this.Log().Warn(NO_CHANGE_MESSAGE);
}
}

Expand Down

0 comments on commit 978fab9

Please sign in to comment.