Skip to content

Commit

Permalink
Add templating to file description
Browse files Browse the repository at this point in the history
  • Loading branch information
agc93 committed Oct 19, 2020
1 parent a2567e6 commit 2c795be
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.100'
dotnet-version: '3.1.403'
- name: Restore Tools
shell: bash
run: |
Expand Down
1 change: 1 addition & 0 deletions src/NexusUploader/NexusUploader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

<ItemGroup>
<PackageReference Include="Flurl" Version="2.8.2" />
<PackageReference Include="Handlebars.Net" Version="1.11.5" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.8" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.1.8" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.8" />
Expand Down
15 changes: 15 additions & 0 deletions src/NexusUploader/UploadCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using Spectre.Cli;
using Spectre.Console;
using ValidationResult = Spectre.Cli.ValidationResult;
using HandlebarsDotNet;
using DescriptionAttribute = System.ComponentModel.DescriptionAttribute;

namespace NexusUploader.Nexus
{
Expand All @@ -28,6 +30,19 @@ public override async Task<int> ExecuteAsync(CommandContext context, Settings se
{
var config = settings.MergedConfiguration;
var fileOpts = new FileOptions(config.FileName, settings.FileVersion) {Description = config.FileDescription };
try
{
var compAction = Handlebars.Compile(fileOpts.Description);
var result = compAction?.Invoke(fileOpts);
if (!string.IsNullOrWhiteSpace(result) && !string.Equals(fileOpts.Description, result)) {
AnsiConsole.MarkupLine("Compiled description template using current file options.");
fileOpts.Description = result;
}
}
catch (System.Exception ex)
{
AnsiConsole.MarkupLine($"[bold red]ERROR[/]: {ex.Message}");
}
if (settings.SkipMainVersionUpdate.IsSet && settings.SkipMainVersionUpdate.Value) {
_logger.LogWarning("Skipping mod version update!");
fileOpts.UpdateMainVersion = false;
Expand Down

0 comments on commit 2c795be

Please sign in to comment.