From 2ed57ec9ac46c4b523996e9a86ebd66f330ecf33 Mon Sep 17 00:00:00 2001 From: genteure Date: Sat, 22 Jun 2024 23:10:06 +0800 Subject: [PATCH] feat(cli): support passing a directory in `--config-override`. fix #590 --- BililiveRecorder.Cli/Program.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/BililiveRecorder.Cli/Program.cs b/BililiveRecorder.Cli/Program.cs index a0e42e2..498cf9f 100644 --- a/BililiveRecorder.Cli/Program.cs +++ b/BililiveRecorder.Cli/Program.cs @@ -130,8 +130,17 @@ namespace BililiveRecorder.Cli if (args.ConfigOverride is not null) { - logger.Information("Using config from {ConfigOverride}", args.ConfigOverride); - config = ConfigParser.LoadFromFile(args.ConfigOverride); + if (Directory.Exists(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 { @@ -231,7 +240,8 @@ namespace BililiveRecorder.Cli 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()); } })