public static void Run() { var pkg = new RantPackage(); var paths = GetPaths(); var outputPath = Property("out", Path.Combine( Directory.GetParent(Environment.CurrentDirectory).FullName, Path.GetFileName(Environment.CurrentDirectory) + ".rantpkg")); Console.WriteLine("Packing..."); if (paths.Length == 0) { Pack(pkg, Environment.CurrentDirectory); } else { foreach (var path in paths) { Pack(pkg, path); } } pkg.Save(outputPath); Console.WriteLine("\nPackage saved to " + outputPath); Console.ResetColor(); }
public static void Run() { var pkg = new RantPackage(); var paths = GetPaths(); var compress = Property("compression", "true") == "true"; var stringTableMode = int.Parse(Property("string-table", "1")); if (stringTableMode < 0 || stringTableMode > 2) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Invalid string table mode."); Console.ResetColor(); return; } var modeEnum = (Rant.IO.Bson.BsonStringTableMode)stringTableMode; Console.WriteLine("Packing..."); var contentDir = Path.GetFullPath(paths.Length == 0 ? Environment.CurrentDirectory : paths[0]); Pack(pkg, contentDir); string outputPath; if (!Flag("old")) { var infoPath = Path.Combine(contentDir, "rantpkg.json"); if (!File.Exists(infoPath)) throw new FileNotFoundException("rantpkg.json missing from root directory."); var info = JsonConvert.DeserializeObject<PackInfo>(File.ReadAllText(infoPath)); pkg.Title = info.Title; pkg.Authors = info.Authors; pkg.Version = RantPackageVersion.Parse(!String.IsNullOrWhiteSpace(Property("version")) ? Property("version") : info.Version); pkg.Description = info.Description; pkg.ID = info.ID; pkg.Tags = info.Tags; foreach (var dep in info.Dependencies) { pkg.AddDependency(dep); } if (!String.IsNullOrWhiteSpace(info.OutputPath)) { outputPath = Path.Combine(contentDir, info.OutputPath, $"{pkg.ID}-{pkg.Version}.rantpkg"); Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); } else { outputPath = Path.Combine(Directory.GetParent(contentDir).FullName, $"{pkg.ID}-{pkg.Version}.rantpkg"); } Console.WriteLine($"String table mode: {modeEnum}"); Console.WriteLine($"Compression: {(compress ? "yes" : "no")}"); Console.WriteLine(compress ? "Compressing and saving..." : "Saving..."); pkg.Save(outputPath, compress, modeEnum); } else { outputPath = Property("out", Path.Combine( Directory.GetParent(Environment.CurrentDirectory).FullName, Path.GetFileName(Environment.CurrentDirectory) + ".rantpkg")); Console.WriteLine("Saving..."); pkg.SaveOld(outputPath); } Console.WriteLine("\nPackage saved to " + outputPath); Console.ResetColor(); }