using System; using System.IO; using XWorld.PublishTool; namespace XWorld.PublishTool.Cli { // 瘦壳:参数解析 → PublishLayout(全部逻辑在 PublishTool 库,有 xUnit 覆盖) internal static class Program { // 退出码:0 成功;1 参数错误;2 发布失败 private static int Main(string[] args) { CliOptions o; try { o = CliOptions.Parse(args); } catch (ArgumentException e) { Console.Error.WriteLine(e.Message); return 1; } try { GameSpec spec = GameSpecJson.ParseFile(o.SpecPath); string key = o.KeyPath == null ? null : File.ReadAllText(o.KeyPath); var layout = new PublishLayout(); if (o.Mode == "server") layout.PublishServer(o.Src, o.Out, spec, key); else layout.PublishClient(o.Src, o.Out, spec, key); Console.WriteLine($"published {o.Mode} {spec.GameId}/{spec.Version} -> {o.Out}" + (key == null ? " [WARN] 未签名(files.txt.sig 为空)" : " [signed]")); return 0; } catch (Exception e) { Console.Error.WriteLine("publish failed: " + e.Message); return 2; } } } }