/* * WARNING: * This tool was created by an LLM based on the SessionZero shared lib project, therefore it is subject to errors and does not reflect the architecture of the SessionZero project. * It was created to be used as a quick and dirty validation tool for the szpack format. */ using SessionZero.Shared.Services; using Spectre.Console; using Spectre.Console.Cli; using System.ComponentModel; using System.Diagnostics.CodeAnalysis; namespace SessionZero.Tools.Packer; public class PackSettings : CommandSettings { [CommandArgument(0, "")] [Description("The root directory of the datapack to pack.")] public required string Input { get; init; } } public class PackCommand : Command { public override int Execute([NotNull] CommandContext context, [NotNull] PackSettings settings, CancellationToken cancellationToken) { AnsiConsole.MarkupLine($"\n[bold white on blue] --- Packing Datapack: {settings.Input} --- [/]"); try { var packDirectoryName = new DirectoryInfo(settings.Input).Name; var outputFilePath = Path.Combine(Path.GetDirectoryName(settings.Input) ?? Environment.CurrentDirectory, $"{packDirectoryName}.szpack"); DatapackService.PackDatapack(settings.Input, outputFilePath); AnsiConsole.MarkupLine($"[green]✅ Successfully created archive: {outputFilePath}[/]"); return 0; } catch (Exception ex) { AnsiConsole.MarkupLine($"\n[bold white on red]❌ ERROR:[/] Failed to pack datapack. Details: {ex.Message}"); return 1; } } }