Program.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System;
  2. using System.Collections.Generic;
  3. namespace Google.ProtocolBuffers.ProtoGen {
  4. /// <summary>
  5. /// Entry point for the Protocol Buffers generator.
  6. /// </summary>
  7. class Program {
  8. static int Main(string[] args) {
  9. try {
  10. GeneratorOptions options = ParseCommandLineArguments(args);
  11. IList<string> validationFailures;
  12. if (!options.TryValidate(out validationFailures)) {
  13. // We've already got the message-building logic in the exception...
  14. InvalidOptionsException exception = new InvalidOptionsException(validationFailures);
  15. Console.WriteLine(exception.Message);
  16. return 1;
  17. }
  18. Generator generator = Generator.CreateGenerator(options);
  19. generator.Generate();
  20. return 0;
  21. } catch (Exception e) {
  22. Console.Error.WriteLine("Caught unhandled exception: {0}", e);
  23. return 1;
  24. }
  25. }
  26. private static GeneratorOptions ParseCommandLineArguments(string[] args) {
  27. GeneratorOptions options = new GeneratorOptions();
  28. string baseDir = "c:\\Users\\Jon\\Documents\\Visual Studio 2008\\Projects\\ProtocolBuffers";
  29. options.OutputDirectory = baseDir + "\\tmp";
  30. options.InputFiles = new[] { baseDir + "\\protos\\nwind.protobin" };
  31. return options;
  32. }
  33. }
  34. }