- When enabling a feature, mis-typing the feature name throws exception, but should give a friendly error message instead.

--HG--
branch : dev
This commit is contained in:
Suha Can 2010-07-09 12:27:53 -07:00
parent caef8cd1e8
commit e795373a86

View File

@ -1,4 +1,5 @@
using System.Linq;
using System.Collections.Generic;
using System.Linq;
using Orchard.Commands;
using Orchard.Utility.Extensions;
@ -45,8 +46,28 @@ namespace Orchard.Modules.Commands {
[CommandName("feature enable")]
public void Enable(params string[] featureNames) {
Context.Output.WriteLine(T("Enabling features {0}", string.Join(",", featureNames)));
_moduleService.EnableFeatures(featureNames);
Context.Output.WriteLine(T("Enabled features {0}", string.Join(",", featureNames)));
bool listAvailableFeatures = false;
List<string> featuresToEnable = new List<string>();
string[] availableFeatures = _moduleService.GetAvailableFeatures().Select(x => x.Descriptor.Name).ToArray();
foreach (var featureName in featureNames) {
if (availableFeatures.Contains(featureName)) {
featuresToEnable.Add(featureName);
}
else {
Context.Output.WriteLine(T("Could not find feature {0}", featureName));
listAvailableFeatures = true;
}
}
if (featuresToEnable.Count != 0) {
_moduleService.EnableFeatures(featuresToEnable);
Context.Output.WriteLine(T("Enabled features {0}", string.Join(",", featuresToEnable)));
}
else {
Context.Output.WriteLine(T("Could not enable features: {0}", string.Join(",", featureNames)));
listAvailableFeatures = true;
}
if (listAvailableFeatures)
Context.Output.WriteLine(T("Available features are : {0}", string.Join(",", availableFeatures)));
}
[CommandHelp("feature disable <feature-name-1> ... <feature-name-n>\r\n\t" + "Disable one or more features")]