feat(cli): support passing a directory in --config-override.

fix #590
This commit is contained in:
genteure 2024-06-22 23:10:06 +08:00
parent 1f6f6216c5
commit 2ed57ec9ac

View File

@ -130,8 +130,17 @@ namespace BililiveRecorder.Cli
if (args.ConfigOverride is not null) if (args.ConfigOverride is not null)
{ {
logger.Information("Using config from {ConfigOverride}", args.ConfigOverride); if (Directory.Exists(args.ConfigOverride))
config = ConfigParser.LoadFromFile(args.ConfigOverride); {
var overrideFile = Path.Combine(args.ConfigOverride, "config.json");
logger.Information("Using config from {ConfigOverride}", overrideFile);
config = ConfigParser.LoadFromFile(overrideFile);
}
else
{
logger.Information("Using config from {ConfigOverride}", args.ConfigOverride);
config = ConfigParser.LoadFromFile(args.ConfigOverride);
}
} }
else else
{ {
@ -231,7 +240,8 @@ namespace BililiveRecorder.Cli
services.AddSingleton(new BasicAuthCredential(sharedArguments.HttpBasicUser ?? string.Empty, sharedArguments.HttpBasicPass ?? string.Empty)); services.AddSingleton(new BasicAuthCredential(sharedArguments.HttpBasicUser ?? string.Empty, sharedArguments.HttpBasicPass ?? string.Empty));
} }
if (sharedArguments.HttpOpenAccess || Environment.GetEnvironmentVariable("BREC_HTTP_OPEN_ACCESS") is not null){ if (sharedArguments.HttpOpenAccess || Environment.GetEnvironmentVariable("BREC_HTTP_OPEN_ACCESS") is not null)
{
services.AddSingleton(new DisableOpenAccessWarningConfig()); services.AddSingleton(new DisableOpenAccessWarningConfig());
} }
}) })