public int Execute(string [] args) { TextReader input = Console.In; TextWriter output = Console.Out; var sc = new ServiceContainer(); var rekoCfg = new DecompilerConfiguration(); var docopt = new Docopt(); IDictionary<string, ValueObject> options; try { options = docopt.Apply(usage, args); } catch (Exception ex) { Console.Error.WriteLine(ex); return 1; } var arch = rekoCfg.GetArchitecture(options["-a"].ToString()); if (arch == null) { Console.WriteLine( "c2xml: unknown architecture '{0}'. Check the c2xml config file for supported architectures.", options["-a"]); return -1; } var envElem = rekoCfg.GetEnvironment(options["-e"].ToString()); if (envElem == null) { Console.WriteLine( "c2xml: unknown environment '{0}'. Check the c2xml config file for supported architectures.", options["-e"]); return -1; } var platform = envElem.Load(sc, arch); try { input = new StreamReader(options["<inputfile>"].ToString()); } catch (Exception ex) { Console.Error.WriteLine("c2xml: unable to open file {0} for reading. {1}", options["<inputfile>"], ex.Message); return 1; } if (options.ContainsKey("<outputfile>") && options["<outputfile>"] != null) { try { output = new StreamWriter(options["<outputfile>"].ToString()); } catch (Exception ex) { Console.Error.WriteLine("c2xml: unable to open file {0} for writing. {1}", options["<outputfile>"], ex.Message); return 1; } } var xWriter = new XmlTextWriter(output) { Formatting = Formatting.Indented }; XmlConverter c = new XmlConverter(input, xWriter, platform); c.Convert(); output.Flush(); return 0; }