Replace ManyConsole with CommandLineParser
This commit is contained in:
1 parent
16acc4f5b0
commit
8793c6c527
9 files changed
+139
-116
No files matched your search
@@ -2,16 +2,37 @@
|
||||
using bts.api.core;
|
||||
using bts.api.synthetic;
|
||||
using bts.api.test;
|
||||
using ManyConsole;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using CommandLine;
|
||||
using bts;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
|
||||
namespace sparkcmd {
|
||||
class Program {
|
||||
|
||||
// static object option<T>(Func<T,int> run) {return run;}
|
||||
// static Type argType(object arg) {
|
||||
// return arg.GetType().GetGenericArguments().First();
|
||||
// }
|
||||
// static int Run(Func<IEnumerable<Error>,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) {
|
||||
mbts.config.Configuration.initialize();
|
||||
var commands = ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program));
|
||||
return ConsoleCommandDispatcher.DispatchCommand(commands, args, Console.Out);
|
||||
// note: this can be made to infer the options type list from the list of delegates
|
||||
return CommandLine.Parser.Default
|
||||
.ParseArguments<ConfigcheckOptions,ScriptClientOptions,TailServiceOptions,ServiceTestOptions,SettingsManagerOptions >(args)
|
||||
.MapResult<ConfigcheckOptions,ScriptClientOptions,TailServiceOptions,ServiceTestOptions,SettingsManagerOptions,int>(
|
||||
Configcheck.Run,
|
||||
ScriptClientCommand.Run,
|
||||
TailService.Run,
|
||||
ServiceTest.Run,
|
||||
SettingsManagerCommand.Run,
|
||||
errors => 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user