static void Main(string[] args) { if (args.Length == 1) { if (args[0].ToLower().EndsWith(".adc")) { AdhocFile adc = null; bool withOffset = true; try { adc = AdhocFile.ReadFromFile(args[0]); } catch (Exception e) { Console.WriteLine($"Errored while reading: {e.Message}"); } adc.Disassemble(Path.ChangeExtension(args[0], ".ad.diss"), withOffset); if (adc.Version == 12) { adc.PrintStrings(Path.ChangeExtension(args[0], ".strings")); } return; } else if (args[0].ToLower().EndsWith(".gpb")) { var gpb = GpbBase.ReadFile(args[0]); if (gpb is null) { Console.WriteLine("Could not parse GPB Header."); return; } string fileName = Path.GetFileNameWithoutExtension(args[0]); string dir = Path.GetDirectoryName(args[0]); gpb.Unpack(Path.GetFileNameWithoutExtension(args[0]), null); return; } } Parser.Default.ParseArguments <PackVerbs, UnpackVerbs, MProjectToBinVerbs, MProjectToTextVerbs>(args) .WithParsed <PackVerbs>(Pack) .WithParsed <UnpackVerbs>(Unpack) .WithParsed <MProjectToBinVerbs>(MProjectToBin) .WithParsed <MProjectToTextVerbs>(MProjectToText); }
public static void Unpack(UnpackVerbs unpackVerbs) { if (unpackVerbs.InputPath.ToLower().EndsWith("gpb")) { Console.WriteLine("Assuming input is GPB"); var gpb = GpbBase.ReadFile(unpackVerbs.InputPath); if (gpb is null) { Console.WriteLine("Could not parse GPB Header."); return; } gpb.Unpack(Path.GetFileNameWithoutExtension(unpackVerbs.InputPath), unpackVerbs.OutputPath); } else if (unpackVerbs.InputPath.EndsWith("mpackage")) { Console.WriteLine("Assuming input is MPackage"); AdhocPackage.ExtractPackage(unpackVerbs.InputPath); } else { Console.WriteLine("Found nothing to unpack - ensure the provided input file has the proper file extension (gpb/mpackage)"); } }