Skip to content

Commit

Permalink
fix: cli defaults (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardochaia authored Mar 6, 2023
1 parent c5196d6 commit 1486c15
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/dotnet-affected/AffectedCli.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ internal static class AffectedCli
public static CommandLineBuilder CreateAffectedCommandLineBuilder()
{
return new CommandLineBuilder(new AffectedRootCommand())
.UseDefaults()
.UseRenderingErrorHandler(new Dictionary<Type, RenderingErrorConfig>
{
[typeof(NoChangesException)] = new(AffectedExitCodes.NothingChanged, new NoChangesView()),
Expand Down
1 change: 1 addition & 0 deletions src/dotnet-affected/Commands/AffectedRootCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ internal class AffectedRootCommand : RootCommand
public AffectedRootCommand()
: base("Determines which projects are affected by a set of changes.")
{
this.Name = "dotnet-affected";
this.AddCommand(new DescribeCommand());

this.AddGlobalOption(AffectedGlobalOptions.RepositoryPathOptions);
Expand Down
31 changes: 31 additions & 0 deletions test/dotnet-affected.Tests/AffectedCliDefaultsTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;

namespace Affected.Cli.Tests
{
/// <summary>
/// Tests for the public API.
/// Ensures that the CLI implements common stuff like --help
/// </summary>
public class AffectedCliDefaultsTests : BaseInvocationTest
{
public AffectedCliDefaultsTests(ITestOutputHelper helper)
: base(helper)
{
}

[Fact]
public async Task When_help_should_output_help()
{
var (output, exitCode) =
await this.InvokeAsync("--help");

Assert.Equal(0, exitCode);

Assert.Contains("Determines which projects are affected by a set of changes.", output);
Assert.Contains("Usage:", output);
Assert.Contains("dotnet-affected [command] [options]", output);
}
}
}

0 comments on commit 1486c15

Please sign in to comment.