mirror of
https://github.com/BililiveRecorder/BililiveRecorder.git
synced 2024-11-15 19:22:19 +08:00
parent
616efe40c9
commit
f232a75a40
|
@ -48,6 +48,7 @@ namespace BililiveRecorder.Cli
|
|||
|
||||
var cmd_run = new Command("run", "Run BililiveRecorder in standard mode")
|
||||
{
|
||||
new Option<string?>(new []{ "--config-override" }, () => null, "Config path override"),
|
||||
new Option<string?>(new []{ "--http-bind", "--bind", "-b" }, () => null, "Bind address for http service"),
|
||||
new Option<string?>(new []{ "--http-basic-user" }, () => null, "Web interface username"),
|
||||
new Option<string?>(new []{ "--http-basic-pass" }, () => null, "Web interface password"),
|
||||
|
@ -115,14 +116,22 @@ namespace BililiveRecorder.Cli
|
|||
Log.Logger = logger;
|
||||
|
||||
path = Path.GetFullPath(path);
|
||||
|
||||
if (args.ConfigOverride is not null)
|
||||
{
|
||||
logger.Information("Using config from {ConfigOverride}", args.ConfigOverride);
|
||||
path = args.ConfigOverride;
|
||||
}
|
||||
|
||||
var config = ConfigParser.LoadFrom(path);
|
||||
if (config is null)
|
||||
{
|
||||
logger.Error("Initialize Error");
|
||||
logger.Error("Config Loading Failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
config.Global.WorkDirectory = path;
|
||||
config.ConfigPathOverride = args.ConfigOverride;
|
||||
|
||||
var serviceProvider = BuildServiceProvider(config, logger);
|
||||
|
||||
|
@ -493,6 +502,8 @@ namespace BililiveRecorder.Cli
|
|||
|
||||
public sealed class RunModeArguments : SharedArguments
|
||||
{
|
||||
public string? ConfigOverride { get; set; } = null;
|
||||
|
||||
public string Path { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
|
|
|
@ -92,8 +92,10 @@ namespace BililiveRecorder.Core.Config
|
|||
}
|
||||
}
|
||||
|
||||
public static bool SaveTo(string directory, V3.ConfigV3 config)
|
||||
public static bool Save(V3.ConfigV3 config)
|
||||
{
|
||||
var directory = config.Global.WorkDirectory;
|
||||
|
||||
if (config.DisableConfigSave)
|
||||
{
|
||||
logger.Debug("Skipping write config because DisableConfigSave is true.");
|
||||
|
@ -108,6 +110,9 @@ namespace BililiveRecorder.Core.Config
|
|||
|
||||
var filepath = Path.Combine(directory, CONFIG_FILE_NAME);
|
||||
|
||||
if (config.ConfigPathOverride is not null)
|
||||
filepath = config.ConfigPathOverride;
|
||||
|
||||
if (json is not null)
|
||||
WriteAllTextWithBackup(filepath, json);
|
||||
|
||||
|
|
|
@ -14,8 +14,13 @@ namespace BililiveRecorder.Core.Config.V3
|
|||
[JsonProperty("rooms")]
|
||||
public List<RoomConfig> Rooms { get; set; } = new List<RoomConfig>();
|
||||
|
||||
// for CLI
|
||||
[JsonIgnore]
|
||||
public bool DisableConfigSave { get; set; } = false; // for CLI
|
||||
public bool DisableConfigSave { get; set; } = false;
|
||||
|
||||
// for CLI
|
||||
[JsonIgnore]
|
||||
public string? ConfigPathOverride { get; set; }
|
||||
}
|
||||
|
||||
public partial class RoomConfig : IFileNameConfig
|
||||
|
|
|
@ -120,7 +120,7 @@ namespace BililiveRecorder.Core
|
|||
public void SaveConfig()
|
||||
{
|
||||
this.Config.Rooms = this.Rooms.Select(x => x.RoomConfig).ToList();
|
||||
ConfigParser.SaveTo(this.Config.Global.WorkDirectory!, this.Config);
|
||||
ConfigParser.Save(this.Config);
|
||||
}
|
||||
|
||||
#region Events
|
||||
|
|
Loading…
Reference in New Issue
Block a user