using bts.api; using bts.api.core; using bts.api.synthetic; using bts.api.test; using System; using System.Linq; using CommandLine; using bts; using System.Collections.Generic; using System.Linq.Expressions; using System.Reflection; using bts.utils; namespace sparkcmd { class Program { // static object option(Func run) {return run;} // static Type argType(object arg) { // return arg.GetType().GetGenericArguments().First(); // } // static int Run(Func,int> on_error, params object[] args) { // var types = args.Select(argType).ToArray(); // var parse = CommandLine.Parser.Default.GetType().GetMethod("ParseArguments", BindingFlags.Public).MakeGenericMethod(types); // return 3; // } static int Main(string[] args) { // Initializing config is up to each individual command // We call provide_command_line here in case config is first // initialized from c++ instead of c# BTSNativeMethods.provide_command_line(args, args.Length); var parser = new Parser(ps => { ps.CaseInsensitiveEnumValues = true; ps.HelpWriter = Console.Out; }); // note: this can be made to infer the options type list from the list of delegates return parser .ParseArguments< ConfigcheckOptions, ScriptClientOptions, TailServiceOptions, ServiceTestOptions, SettingsManagerOptions, TestCommandOptions, OrderStressOptions, MBOCommandOptions >(BTS.remove_config_arg(args)) .MapResult< ConfigcheckOptions, ScriptClientOptions, TailServiceOptions, ServiceTestOptions, SettingsManagerOptions, TestCommandOptions, OrderStressOptions, MBOCommandOptions, int>( Configcheck.Run, ScriptClientCommand.Run, TailService.Run, ServiceTest.Run, SettingsManagerCommand.Run, TestCommand.Run, OrderStress.Run, MBOCommand.Run, errors => 1); } } }