diff --git a/src/Bau.NuGet/Bau.NuGet.csproj b/src/Bau.NuGet/Bau.NuGet.csproj
index 23d0ff2..98efe96 100644
--- a/src/Bau.NuGet/Bau.NuGet.csproj
+++ b/src/Bau.NuGet/Bau.NuGet.csproj
@@ -48,6 +48,7 @@
Properties\CommonAssemblyInfo.cs
+
diff --git a/src/Bau.NuGet/Command.cs b/src/Bau.NuGet/Command.cs
index 3f29849..c27df7d 100644
--- a/src/Bau.NuGet/Command.cs
+++ b/src/Bau.NuGet/Command.cs
@@ -20,7 +20,7 @@ protected Command()
public string NuGetExePathOverride { get; set; }
- public string Verbosity { get; set; }
+ public Verbosity? Verbosity { get; set; }
public bool NonInteractive { get; set; }
@@ -33,10 +33,10 @@ public IEnumerable CreateCommandLineArguments()
yield return argument;
}
- if (!string.IsNullOrWhiteSpace(this.Verbosity))
+ if (this.Verbosity.HasValue)
{
// NOTE: Verbose is a valid flag but it is deprecated in favor of Verbosity and should not be used
- yield return "-Verbosity " + this.Verbosity;
+ yield return "-Verbosity " + this.Verbosity.ToString().ToLowerInvariant();
}
if (this.NonInteractive)
@@ -44,7 +44,7 @@ public IEnumerable CreateCommandLineArguments()
yield return "-NonInteractive";
}
- if (!string.IsNullOrWhiteSpace(this.ConfigFile))
+ if (this.ConfigFile != null)
{
yield return "-ConfigFile " + this.QuoteWrapCliValue(this.ConfigFile);
}
diff --git a/src/Bau.NuGet/CommandExtensions.cs b/src/Bau.NuGet/CommandExtensions.cs
index a517595..f2d36a0 100644
--- a/src/Bau.NuGet/CommandExtensions.cs
+++ b/src/Bau.NuGet/CommandExtensions.cs
@@ -18,7 +18,7 @@ public static T WithNuGetExePathOverride(this T command, string nugetExePath)
return command;
}
- public static T WithVerbosity(this T command, string verbosity) where T : Command
+ public static T WithVerbosity(this T command, Verbosity? verbosity) where T : Command
{
command.Verbosity = verbosity;
return command;
@@ -26,17 +26,17 @@ public static T WithVerbosity(this T command, string verbosity) where T : Com
public static T WithVerbosityDetailed(this T command) where T : Command
{
- return command.WithVerbosity("detailed");
+ return command.WithVerbosity(Verbosity.Detailed);
}
public static T WithVerbosityQuiet(this T command) where T : Command
{
- return command.WithVerbosity("quiet");
+ return command.WithVerbosity(Verbosity.Quiet);
}
public static T WithVerbosityNormal(this T command) where T : Command
{
- return command.WithVerbosity("normal");
+ return command.WithVerbosity(Verbosity.Normal);
}
public static T WithInteraction(this T command) where T : Command
diff --git a/src/Bau.NuGet/Verbosity.cs b/src/Bau.NuGet/Verbosity.cs
new file mode 100644
index 0000000..a535d94
--- /dev/null
+++ b/src/Bau.NuGet/Verbosity.cs
@@ -0,0 +1,13 @@
+//
+// Copyright (c) Bau contributors. (baubuildch@gmail.com)
+//
+
+namespace BauNuGet
+{
+ public enum Verbosity
+ {
+ Normal,
+ Quiet,
+ Detailed,
+ }
+}
diff --git a/src/test/Bau.NuGet.Test.Unit/CommandFacts.cs b/src/test/Bau.NuGet.Test.Unit/CommandFacts.cs
index 1bec833..1e62c85 100644
--- a/src/test/Bau.NuGet.Test.Unit/CommandFacts.cs
+++ b/src/test/Bau.NuGet.Test.Unit/CommandFacts.cs
@@ -27,10 +27,10 @@ public static void DoesNotCreateVerbosityArgumentWhenNotSpecified()
}
[Theory]
- [InlineData("normal")]
- [InlineData("quiet")]
- [InlineData("detailed")]
- public static void CreatesVerbosityArgumentWhenSpecified(string verbosity)
+ [InlineData(Verbosity.Normal)]
+ [InlineData(Verbosity.Quiet)]
+ [InlineData(Verbosity.Detailed)]
+ public static void CreatesVerbosityArgumentWhenSpecified(Verbosity verbosity)
{
// arrange
var command = new DummyCommand { Verbosity = verbosity };
@@ -39,29 +39,26 @@ public static void CreatesVerbosityArgumentWhenSpecified(string verbosity)
var arguments = command.CreateCommandLineArguments().ToArray();
// assert
- arguments.Should().Contain("-Verbosity " + verbosity);
+ arguments.Should().Contain("-Verbosity " + verbosity.ToString().ToLowerInvariant());
}
[Fact]
public static void PropertyVerbosityFluent()
{
// arrange
- var command = new DummyCommand();
var normal = new DummyCommand();
var quiet = new DummyCommand();
var detailed = new DummyCommand();
// act
- command.WithVerbosity("Grumbling");
normal.WithVerbosityNormal();
quiet.WithVerbosityQuiet();
detailed.WithVerbosityDetailed();
// assert
- command.Verbosity.Should().Be("Grumbling");
- Assert.Equal("Normal", normal.Verbosity, StringComparer.OrdinalIgnoreCase);
- Assert.Equal("Quiet", quiet.Verbosity, StringComparer.OrdinalIgnoreCase);
- Assert.Equal("Detailed", detailed.Verbosity, StringComparer.OrdinalIgnoreCase);
+ normal.Verbosity.Should().Be(Verbosity.Normal);
+ quiet.Verbosity.Should().Be(Verbosity.Quiet);
+ detailed.Verbosity.Should().Be(Verbosity.Detailed);
}
[Fact]