public static void Dump(Options options) { using (var streamProvider = new PipBoyStreamProvider(options.RawFile)) { Stream stream; if (options.Host != null) { stream = streamProvider.Connect(options.Host, options.Port); } else if (options.InputFile != null) { stream = streamProvider.ReadFile(options.InputFile); } else { throw new ArgumentException(); } using (stream) { var dumper = new Dumper(options.GameobjectsFile); var dumpThread = new Thread(_ => dumper.Dump(stream)); dumpThread.Start(); Console.WriteLine("Dump running... press key to exit"); while (dumpThread.IsAlive && !Console.KeyAvailable) { Thread.Sleep(100); } dumper.SignalStop(); dumpThread.Join(); } } }
static void Main(string[] args) { var options = new Options(); if (new Parser(settings => { settings.MutuallyExclusive = true; settings.HelpWriter = Console.Error; }).ParseArguments(args, options)) { var inputFile = options.InputFile; if (inputFile == null && options.Host == null) { Console.Error.WriteLine("Error: either an input file or a host name has to be specified."); Console.Error.WriteLine(options.GetUsage()); return; } if (inputFile != null && !File.Exists(inputFile)) { Console.Error.WriteLine("Error: input file not found."); return; } var rawFile = options.RawFile; if (rawFile != null && !ValidateOutputFile(rawFile)) { Console.Error.WriteLine("Error: invalid output file name for raw data."); return; } var gameobjectsFile = options.GameobjectsFile; if (gameobjectsFile != null && !ValidateOutputFile(gameobjectsFile)) { Console.Error.WriteLine("Error: invalid output file name for gameobjects."); } try { Dump(options); } catch (Exception e) { Console.Error.WriteLine("Unexpected error: " + e.Message); } } }