public int Execute(TextWriter error, params string[] args) { ProxyGeneratorOptions generatorOptions = new ProxyGeneratorOptions(); if (Parser.ParseHelp(args)) { Parser.ParseArguments(args, generatorOptions); } else if (Parser.ParseArguments(args, generatorOptions) == false) { error.WriteLine(Parser.ArgumentsUsage(generatorOptions.GetType())); return(Error.InvalidArguments); } if (_proxyGenerator == null) { try { _proxyGenerator = CreateProxyGenerator(generatorOptions.Generator); } catch (Exception exc) { error.WriteLine(exc.Message); return(Error.CreateProxyGenerator); } } generatorOptions = _proxyGenerator.GetOptions(); if (generatorOptions == null) { error.WriteLine("{0}.GetOptions() returned null. Please use a different Generator.", _proxyGenerator.GetType().FullName); return(Error.InvalidGenerator); } if (Parser.ParseHelp(args)) { error.WriteLine(Parser.ArgumentsUsage(generatorOptions.GetType())); return(Error.None); } if (Parser.ParseArguments(args, generatorOptions) == false) { error.WriteLine(Parser.ArgumentsUsage(generatorOptions.GetType())); return(Error.InvalidArguments); } try { _proxyGenerator.Generate(generatorOptions); } catch (Exception exc) { error.WriteLine(exc.Message); error.WriteLine(exc.StackTrace); return(Error.Unknown); } return(Error.None); }