diff --git a/ModerationClient/Services/CommandLineConfiguration.cs b/ModerationClient/Services/CommandLineConfiguration.cs
index 63c3691..4f7da2d 100644
--- a/ModerationClient/Services/CommandLineConfiguration.cs
+++ b/ModerationClient/Services/CommandLineConfiguration.cs
@@ -2,15 +2,14 @@ using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
+using System.Text.Json;
using ArcaneLibs;
-using Microsoft.Extensions.Logging;
+using ArcaneLibs.Extensions;
namespace ModerationClient.Services;
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
public record CommandLineConfiguration {
- private readonly string? _loginData;
-
public static CommandLineConfiguration FromProcessArgs() {
// logger.LogInformation("Command line arguments: " + string.Join(", ", Environment.GetCommandLineArgs()));
CommandLineConfiguration cfg = FromSerialised(Environment.GetCommandLineArgs());
@@ -27,24 +26,27 @@ public record CommandLineConfiguration {
if (!string.IsNullOrWhiteSpace(cfg.LoginData)) {
File.WriteAllText(Path.Combine(cfg.ProfileDirectory, "login.json"), cfg.LoginData);
}
+
+
return cfg;
}
-
public string[] Serialise() {
+ var current = FromProcessArgs();
List<string> args = new();
- if (Profile != "default") args.AddRange(["--profile", Profile]);
+ if (Profile != current.Profile) args.AddRange(["--profile", Profile]);
if (IsTemporary) args.Add("--temporary");
if (Math.Abs(Scale - 1f) > float.Epsilon) args.AddRange(["--scale", Scale.ToString()]);
- if (ProfileDirectory != Util.ExpandPath("$HOME/.local/share/ModerationClient/default")) args.AddRange(["--profile-dir", ProfileDirectory]);
- if (!string.IsNullOrWhiteSpace(_loginData)) args.AddRange(["--login-data", _loginData!]);
+ if (ProfileDirectory != current.ProfileDirectory) args.AddRange(["--profile-dir", ProfileDirectory]);
+ if (!string.IsNullOrWhiteSpace(_loginData) && _loginData != current.LoginData) args.AddRange(["--login-data", _loginData!]);
+ if (TestConfiguration is not null && TestConfiguration != current.TestConfiguration) args.AddRange(["--test-config", TestConfiguration!.ToJson()]);
return args.ToArray();
}
-
public static CommandLineConfiguration FromSerialised(string[] args) {
CommandLineConfiguration cfg = new();
for (var i = 0; i < args.Length; i++) {
switch (args[i]) {
case "--profile":
+ case "-p":
cfg = cfg with { Profile = args[++i] };
break;
case "--temporary":
@@ -59,12 +61,16 @@ public record CommandLineConfiguration {
case "--login-data":
cfg = cfg with { LoginData = args[++i] };
break;
+ case "--test-config":
+ cfg = cfg with { testConfiguration = args[++i] };
+ break;
}
}
return cfg;
}
+ private readonly string? _loginData;
public string Profile { get; init; } = "default";
public bool IsTemporary { get; init; }
@@ -78,4 +84,15 @@ public record CommandLineConfiguration {
_loginData = value;
}
}
+
+ private string? testConfiguration {
+ get => TestConfiguration?.ToJson();
+ init => TestConfiguration = value is null ? null : JsonSerializer.Deserialize<TestConfig>(value);
+ }
+
+ public TestConfig? TestConfiguration { get; init; }
+
+ public class TestConfig {
+ public List<string> Mxids { get; set; } = new();
+ }
}
\ No newline at end of file
|