From b2ed3f0d07cba0942c7a0002f6e06b2debdce213 Mon Sep 17 00:00:00 2001 From: Bernhard Richter Date: Tue, 26 Mar 2019 10:48:19 +0100 Subject: [PATCH] Don't execute default step when help is invoked --- build/dotnet-steps.nuspec | 2 +- src/steps.csx | 16 +++++++++++----- src/steps.tests.csx | 1 + 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/build/dotnet-steps.nuspec b/build/dotnet-steps.nuspec index 36a5a71..827fbb5 100644 --- a/build/dotnet-steps.nuspec +++ b/build/dotnet-steps.nuspec @@ -3,7 +3,7 @@ dotnet-steps dotnet-steps - 0.0.1 + 0.0.2 A small step for man kind, but a HUGE leap for build scripts. Bernhard Richter Bernhard Richter diff --git a/src/steps.csx b/src/steps.csx index d548fad..ff1445e 100644 --- a/src/steps.csx +++ b/src/steps.csx @@ -125,6 +125,12 @@ private static class StepRunner var stepDelegates = GetStepDelegates(); + if (stepNames.Contains("help", StringComparer.OrdinalIgnoreCase)) + { + ShowHelp(stepDelegates.Values.ToArray()); + return; + } + if (stepDelegates.Keys.Intersect(stepNames).Count() == 0) { await GetDefaultDelegate(stepDelegates)(); @@ -134,11 +140,11 @@ private static class StepRunner { _callStack.Clear(); - if (stepName.Equals("help", StringComparison.OrdinalIgnoreCase)) - { - stepDelegates.Values.ToArray().ShowHelp(); - continue; - } + // if (stepName.Equals("help", StringComparison.OrdinalIgnoreCase)) + // { + // stepDelegates.Values.ToArray().ShowHelp(); + // break; + // } if (stepDelegates.TryGetValue(stepName, out var stepDelegate)) { diff --git a/src/steps.tests.csx b/src/steps.tests.csx index 96435e7..7da8ac2 100755 --- a/src/steps.tests.csx +++ b/src/steps.tests.csx @@ -44,6 +44,7 @@ public async Task ShouldShowHelp() TestContext.StandardOut.Should().Contain("Available Steps"); TestContext.StandardOut.Should().Contain("This is step one"); TestContext.StandardOut.Should().Contain("step1 (default)"); + TestContext.StandardOut.Should().NotContain("Steps Summary"); } public async Task ShouldReportNestedStep()