public static int Main(string[] args) { var options = new Options(); if (!ParseCommandLineOptions(args, options)) return 1; if (!Directory.Exists(options.OutputDir)) Directory.CreateDirectory(options.OutputDir); if(!Generate(options.Assembly, options.OutputDir, options.CreateApi)) return 1; return 0; }
static bool ParseCommandLineOptions(String[] args, Options options) { var set = new OptionSet() { // Compiler options { "a|api", "Separate rpc code into an API dll.", v => options.CreateApi = true }, { "ns|namespace=", v => options.OutputNamespace = v }, { "o|outdir=", v => options.OutputDir = v }, { "debug", v => options.OutputDebug = true }, // Misc. options { "v|verbose", v => { options.Verbose = true; } }, { "h|?|help", v => options.ShowHelpText = v != null }, }; if (args.Length == 0 || options.ShowHelpText) { ShowHelp(set); return false; } try { options.Assembly = set.Parse(args)[0]; } catch (OptionException) { Console.WriteLine("Error parsing the command line."); ShowHelp(set); return false; } return true; }