From 8364b0e2ae7cce0ff304efd48e6df18321b072fe Mon Sep 17 00:00:00 2001 From: Joel Bennett Date: Tue, 3 Mar 2015 02:16:13 -0500 Subject: [PATCH] (GH-132) Change source_list to return a list of sources --- .../ChocolateyConfigSettingsService.cs | 19 +++++++++++++++---- .../IChocolateyConfigSettingsService.cs | 5 +++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/chocolatey/infrastructure.app/services/ChocolateyConfigSettingsService.cs b/src/chocolatey/infrastructure.app/services/ChocolateyConfigSettingsService.cs index f45624b3e9..d1f4db70ca 100644 --- a/src/chocolatey/infrastructure.app/services/ChocolateyConfigSettingsService.cs +++ b/src/chocolatey/infrastructure.app/services/ChocolateyConfigSettingsService.cs @@ -16,6 +16,7 @@ namespace chocolatey.infrastructure.app.services { using System; + using System.Collections.Generic; using System.Linq; using configuration; using infrastructure.services; @@ -43,12 +44,22 @@ public void noop(ChocolateyConfiguration configuration) this.Log().Info("Would have made a change to the configuration."); } - public void source_list(ChocolateyConfiguration configuration) + public IEnumerable source_list(ChocolateyConfiguration configuration) { + var list = new List(); foreach (var source in configFileSettings.Sources) { - this.Log().Info(() => "{0}{1} - {2}".format_with(source.Id, source.Disabled ? " [Disabled]" : string.Empty, source.Value)); - } + if (configuration.RegularOuptut) { + this.Log().Info(() => "{0}{1} - {2}".format_with(source.Id, source.Disabled ? " [Disabled]" : string.Empty, source.Value)); + } + list.Add(new ChocolateySource { + Id = source.Id, + Value = source.Value, + Disabled = source.Disabled, + Authenticated = string.IsNullOrWhiteSpace(source.Password) + }); + } + return list; } public void source_add(ChocolateyConfiguration configuration) @@ -232,4 +243,4 @@ public void set_api_key(ChocolateyConfiguration configuration) } } } -} \ No newline at end of file +} diff --git a/src/chocolatey/infrastructure.app/services/IChocolateyConfigSettingsService.cs b/src/chocolatey/infrastructure.app/services/IChocolateyConfigSettingsService.cs index 3d29562e6b..80628a4281 100644 --- a/src/chocolatey/infrastructure.app/services/IChocolateyConfigSettingsService.cs +++ b/src/chocolatey/infrastructure.app/services/IChocolateyConfigSettingsService.cs @@ -16,12 +16,13 @@ namespace chocolatey.infrastructure.app.services { using System; + using System.Collections.Generic; using configuration; public interface IChocolateyConfigSettingsService { void noop(ChocolateyConfiguration configuration); - void source_list(ChocolateyConfiguration configuration); + IEnumerable source_list(ChocolateyConfiguration configuration); void source_add(ChocolateyConfiguration configuration); void source_remove(ChocolateyConfiguration configuration); void source_disable(ChocolateyConfiguration configuration); @@ -32,4 +33,4 @@ public interface IChocolateyConfigSettingsService string get_api_key(ChocolateyConfiguration configuration, Action keyAction); void set_api_key(ChocolateyConfiguration configuration); } -} \ No newline at end of file +}