aboutsummaryrefslogtreecommitdiff
path: root/src/ProtoGen/Program.cs
diff options
context:
space:
mode:
authorJon Skeet <skeet@pobox.com>2008-10-22 13:30:34 +0100
committerJon Skeet <skeet@pobox.com>2008-10-22 13:30:34 +0100
commit6803686bc06c4d96afd9bd2637f7b37a58596699 (patch)
tree4b21c563f4cd4e399fbc0b253bc2f15e822eae88 /src/ProtoGen/Program.cs
parentf0589506c96600dcd01319b9d1929d87505f3daa (diff)
downloadprotobuf-6803686bc06c4d96afd9bd2637f7b37a58596699.tar.gz
protobuf-6803686bc06c4d96afd9bd2637f7b37a58596699.tar.bz2
protobuf-6803686bc06c4d96afd9bd2637f7b37a58596699.zip
First cut at new layout
Diffstat (limited to 'src/ProtoGen/Program.cs')
-rw-r--r--src/ProtoGen/Program.cs47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/ProtoGen/Program.cs b/src/ProtoGen/Program.cs
new file mode 100644
index 00000000..08cad358
--- /dev/null
+++ b/src/ProtoGen/Program.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using Google.ProtocolBuffers.DescriptorProtos;
+
+namespace Google.ProtocolBuffers.ProtoGen {
+ /// <summary>
+ /// Entry point for the Protocol Buffers generator.
+ /// </summary>
+ class Program {
+ static int Main(string[] args) {
+ try {
+ // Hack to make sure everything's initialized
+ DescriptorProtoFile.Descriptor.ToString();
+ GeneratorOptions options = ParseCommandLineArguments(args);
+
+ IList<string> validationFailures;
+ if (!options.TryValidate(out validationFailures)) {
+ // We've already got the message-building logic in the exception...
+ InvalidOptionsException exception = new InvalidOptionsException(validationFailures);
+ Console.WriteLine(exception.Message);
+ return 1;
+ }
+
+ Generator generator = Generator.CreateGenerator(options);
+ generator.Generate();
+
+
+ return 0;
+ } catch (Exception e) {
+ Console.Error.WriteLine("Error: {0}", e.Message);
+ Console.Error.WriteLine();
+ Console.Error.WriteLine("Detailed exception information: {0}", e);
+ return 1;
+ }
+ }
+
+ private static GeneratorOptions ParseCommandLineArguments(string[] args) {
+ GeneratorOptions options = new GeneratorOptions();
+ //string baseDir = "c:\\Users\\Jon\\Documents\\Visual Studio 2008\\Projects\\ProtocolBuffers";
+ //options.OutputDirectory = baseDir + "\\tmp";
+ //options.InputFiles = new[] { baseDir + "\\protos\\nwind-solo.protobin" };
+ options.OutputDirectory = ".";
+ options.InputFiles = args;
+ return options;
+ }
+ }
+} \ No newline at end of file