Add UpdateMetadataCommands to update build time

This commit is contained in:
Thorsten Sommer 2025-04-13 11:55:36 +02:00
parent ecbe75a3e3
commit 5d74df36a8
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
2 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,26 @@
namespace Build.Commands;
// ReSharper disable ClassNeverInstantiated.Global
// ReSharper disable UnusedType.Global
// ReSharper disable UnusedMember.Global
public sealed class UpdateMetadataCommands
{
[Command("test", Description = "Test command")]
public async Task Test()
{
await this.UpdateBuildTime();
}
private async Task UpdateBuildTime()
{
var pathMetadata = Environment.GetMetadataPath();
var lines = await File.ReadAllLinesAsync(pathMetadata, Encoding.UTF8);
var buildTime = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss") + " UTC";
Console.WriteLine($"- Updating build time from '{lines[1]}' to '{buildTime}'.");
lines[1] = buildTime;
await File.WriteAllLinesAsync(pathMetadata, lines, Encoding.UTF8);
}
}

View File

@ -3,4 +3,5 @@
var builder = CoconaApp.CreateBuilder(); var builder = CoconaApp.CreateBuilder();
var app = builder.Build(); var app = builder.Build();
app.AddCommands<CheckRidsCommand>(); app.AddCommands<CheckRidsCommand>();
app.AddCommands<UpdateMetadataCommands>();
app.Run(); app.Run();