Skip to content

Commit

Permalink
refactor: Simplify handling of no arguments by removing redundant met…
Browse files Browse the repository at this point in the history
…hod and directly writing help output
  • Loading branch information
github-actions[bot] committed Dec 2, 2024
1 parent 9016337 commit 053804e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
18 changes: 4 additions & 14 deletions AzureLiquid.Preview/PreviewProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ public static PreviewProcess Create(string[] args)
preview.Output = preview._args.ParsePath(args, "output");
preview.ShouldWatch = PreviewProcessArguments.HasArgument(args, "watch");

HandleNoArgumentsPassed(args, preview);
if (args.Length == 0)
{
preview.WriteHelpOutput();
}

if (preview.CanRender)
{
Expand Down Expand Up @@ -155,19 +158,6 @@ private static void LogMissingFiles(PreviewProcess preview)
preview.LogMessage();
}

/// <summary>
/// Handles the scenario where no arguments are passed to the application.
/// </summary>
/// <param name="args">The array of arguments passed to the application.</param>
/// <param name="preview">The instance of <see cref="PreviewProcess" /> to handle the output.</param>
private static void HandleNoArgumentsPassed(string[] args, PreviewProcess preview)
{
if (args == null || args.Length == 0)
{
preview.WriteHelpOutput();
}
}

/// <summary>
/// Writes the help output.
/// </summary>
Expand Down
3 changes: 2 additions & 1 deletion AzureLiquid.Tests/PreviewProcessTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ public void EnsureFileReadExceptionHandling()
public void EnsureHelpMessageShown()
{
// Arrange
var instance = PreviewProcess.Create(null!);
var empty = new string[0];

Check notice on line 190 in AzureLiquid.Tests/PreviewProcessTests.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Use 'Array.Empty<T>()'

Use 'Array.Empty()'
var instance = PreviewProcess.Create(empty);

// Act
var result = instance.Render();
Expand Down

0 comments on commit 053804e

Please sign in to comment.