Skip to content

Commit

Permalink
(chocolateyGH-132) Change source_list to return a list of sources
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaykul committed Mar 4, 2015
1 parent 8702e01 commit 8364b0e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
Expand Up @@ -16,6 +16,7 @@
namespace chocolatey.infrastructure.app.services
{
using System;
using System.Collections.Generic;
using System.Linq;
using configuration;
using infrastructure.services;
Expand Down Expand Up @@ -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<ChocolateySource> source_list(ChocolateyConfiguration configuration)
{
var list = new List<ChocolateySource>();
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)
Expand Down Expand Up @@ -232,4 +243,4 @@ public void set_api_key(ChocolateyConfiguration configuration)
}
}
}
}
}
Expand Up @@ -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<ChocolateySource> source_list(ChocolateyConfiguration configuration);
void source_add(ChocolateyConfiguration configuration);
void source_remove(ChocolateyConfiguration configuration);
void source_disable(ChocolateyConfiguration configuration);
Expand All @@ -32,4 +33,4 @@ public interface IChocolateyConfigSettingsService
string get_api_key(ChocolateyConfiguration configuration, Action<ConfigFileApiKeySetting> keyAction);
void set_api_key(ChocolateyConfiguration configuration);
}
}
}

0 comments on commit 8364b0e

Please sign in to comment.