Skip to content

Commit

Permalink
feat: Add support for 'watch' argument in PreviewProcess and refactor…
Browse files Browse the repository at this point in the history
… argument matching logic
  • Loading branch information
github-actions[bot] committed Dec 2, 2024
1 parent 130b6c7 commit aa03101
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions AzureLiquid.Preview/PreviewProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public static PreviewProcess Create(string[] args)
preview.Template = preview._args.ParsePath(args, "template");
preview.Content = preview._args.ParsePath(args, "content");
preview.Output = preview._args.ParsePath(args, "output");
preview.ShouldWatch = PreviewProcessArguments.HasArgument(args, "watch");

HandleNoArgumentsPassed(args, preview);

Expand Down Expand Up @@ -195,19 +196,6 @@ private static void WriteErrorLine(string error)
Console.ForegroundColor = ConsoleColor.White;
}

/// <summary>
/// Determines whether the argument matches the partial argument key name.
/// </summary>
/// <param name="arg">The argument.</param>
/// <param name="key">The key.</param>
/// <returns>
/// <c>true</c> if argument found; otherwise, <c>false</c>.
/// </returns>
private static bool IsArgMatch(string arg, string key)
{
return string.CompareOrdinal(arg, "--" + key) == 0;
}

/// <summary>
/// Renders the output using the specified properties of the instance.
/// </summary>
Expand All @@ -233,12 +221,9 @@ public string Render()
}

var parser = new LiquidParser();
if (!SetParserContent(parser, content))
{
return string.Empty;
}

return RenderTemplate(parser, template);
return !SetParserContent(parser, content) ?
string.Empty :
RenderTemplate(parser, template);
}

/// <summary>
Expand Down

0 comments on commit aa03101

Please sign in to comment.