improvement: Polish clis in DataStreamSuite
Specifically PubSubServer, DataStreamPublisher and DSQA * Use CommandLineParser (nuget pkg) * Clean up csproj files a bit while we're at it
This commit is contained in:
1 parent
63306173b1
commit
306c572b53
13 files changed
+501
-229
No files matched your search
@@ -1,40 +1,46 @@
|
||||
using BCG;
|
||||
|
||||
using bts.utils;
|
||||
using bts;
|
||||
using bts.api.core;
|
||||
|
||||
using Bts.DataStreamQueryAnalyzer;
|
||||
|
||||
using CommandLine;
|
||||
|
||||
using mbts.config;
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.Threading.Tasks;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
static class Program {
|
||||
static void init(string[] args) {
|
||||
Func<string, string, Task> login = async (l, p) => {
|
||||
var login = l;
|
||||
var passwd = p;
|
||||
var service_ctx = bts.api.core.ServiceContext.create();
|
||||
await service_ctx.login(login, passwd);
|
||||
};
|
||||
BTSNativeMethods.provide_command_line(args, args.Length);
|
||||
Configuration.initialize();
|
||||
Task.Run(async () => await login("bts", String.Empty));
|
||||
}
|
||||
[STAThread]
|
||||
static void Main(string[] args) {
|
||||
init(args);
|
||||
string args_concat = String.Empty;
|
||||
args.ToList().ForEach(t => args_concat += t);
|
||||
var init_log = $"Starting DSQA args: {args_concat} len: {args.Length}";
|
||||
bts.Log.Gen.info(init_log);
|
||||
Console.WriteLine(init_log);
|
||||
Console.WriteLine("Launching Main Window");
|
||||
MainForm mainForm = new MainForm();
|
||||
if (args.Length > 0) {
|
||||
mainForm.loadFile(args[0]);
|
||||
static async Task Main(string[] args) {
|
||||
await Parser.Default.ParseArguments<DataStreamQueryAnalyzerConfig>(args)
|
||||
.MapResult(RunAsync, errs => Task.FromResult(1));
|
||||
|
||||
async Task<int> RunAsync(DataStreamQueryAnalyzerConfig cfg) {
|
||||
try {
|
||||
cfg.MergeWithConfigFile();
|
||||
Configuration.initialize(cfg.Sparkd);
|
||||
Log.Gen.info("Starting DataStreamQueryAnalyzer");
|
||||
var service_ctx = ServiceContext.create(cfg.Sparkd);
|
||||
await service_ctx.login(cfg.User ?? "bts", cfg.Password ?? string.Empty);
|
||||
Log.Gen.info("Launching Main Window");
|
||||
var mainForm = new MainForm();
|
||||
if (cfg.StreamFile is not null) {
|
||||
mainForm.loadFile(cfg.StreamFile);
|
||||
}
|
||||
Application.Run(mainForm);
|
||||
} catch (Exception ex) {
|
||||
// Write the error to console first, in case the logging system is compromised.
|
||||
var error_msg = $"DataStreamPublisher threw exception:\n{ex}";
|
||||
Console.Error.WriteLine(error_msg);
|
||||
Console.Error.Flush();
|
||||
bts.Log.Gen.error(error_msg);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Application.Run(mainForm);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user