fix(headless): complete connected movement gate

This commit is contained in:
Erik 2026-07-27 10:26:44 +02:00
parent fd9559a063
commit 3f3401257c
11 changed files with 756 additions and 48 deletions

View file

@ -3,7 +3,8 @@ namespace AcDream.Headless.Configuration;
internal sealed record HeadlessCommandLine(
string Command,
string ConfigurationPath,
HeadlessPathOverrides Paths)
HeadlessPathOverrides Paths,
HeadlessDirectCredentials? DirectCredentials)
{
internal static HeadlessCommandLine Parse(
IReadOnlyList<string> arguments)
@ -20,6 +21,8 @@ internal sealed record HeadlessCommandLine(
string? configDirectory = null;
string? dataDirectory = null;
string? cacheDirectory = null;
string? user = null;
string? password = null;
for (int index = 1; index < arguments.Count; index += 2)
{
if (index + 1 >= arguments.Count)
@ -50,6 +53,14 @@ internal sealed record HeadlessCommandLine(
case "--cache-dir":
SetOnce(ref cacheDirectory, value);
break;
case "-user":
case "--user":
SetOnce(ref user, value);
break;
case "-password":
case "--password":
SetOnce(ref password, value);
break;
default:
throw new HeadlessCommandLineException(
"Unknown command option.");
@ -61,6 +72,16 @@ internal sealed record HeadlessCommandLine(
throw new HeadlessCommandLineException(
"The --config option is required.");
}
if ((user is null) != (password is null))
{
throw new HeadlessCommandLineException(
"The user and password options must be supplied together.");
}
if (user is not null && command != "run")
{
throw new HeadlessCommandLineException(
"Direct credentials are valid only for run mode.");
}
return new HeadlessCommandLine(
command,
@ -68,7 +89,10 @@ internal sealed record HeadlessCommandLine(
new HeadlessPathOverrides(
configDirectory,
dataDirectory,
cacheDirectory));
cacheDirectory),
user is null
? null
: new HeadlessDirectCredentials(user, password!));
}
private static void SetOnce(ref string? destination, string value)
@ -81,3 +105,7 @@ internal sealed record HeadlessCommandLine(
destination = value;
}
}
internal sealed record HeadlessDirectCredentials(
string User,
string Password);