mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-05-04 11:33:37 +00:00
Add DISCORDCHATEXPORTER_SETTINGS_PATH env var override for settings file path (#1500)
Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,4 @@
|
|||||||
using System;
|
using System.Text.Json.Serialization;
|
||||||
using System.IO;
|
|
||||||
using System.Text.Json.Serialization;
|
|
||||||
using Cogwheel;
|
using Cogwheel;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using DiscordChatExporter.Core.Discord;
|
using DiscordChatExporter.Core.Discord;
|
||||||
@@ -13,10 +11,7 @@ namespace DiscordChatExporter.Gui.Services;
|
|||||||
|
|
||||||
[ObservableObject]
|
[ObservableObject]
|
||||||
public partial class SettingsService()
|
public partial class SettingsService()
|
||||||
: SettingsBase(
|
: SettingsBase(StartOptions.Current.SettingsPath, SerializerContext.Default)
|
||||||
Path.Combine(AppContext.BaseDirectory, "Settings.dat"),
|
|
||||||
SerializerContext.Default
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
public partial bool IsUkraineSupportMessageEnabled { get; set; } = true;
|
public partial bool IsUkraineSupportMessageEnabled { get; set; } = true;
|
||||||
|
|||||||
24
DiscordChatExporter.Gui/StartOptions.cs
Normal file
24
DiscordChatExporter.Gui/StartOptions.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace DiscordChatExporter.Gui;
|
||||||
|
|
||||||
|
public partial class StartOptions
|
||||||
|
{
|
||||||
|
public required string SettingsPath { get; init; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public partial class StartOptions
|
||||||
|
{
|
||||||
|
public static StartOptions Current { get; } =
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
SettingsPath =
|
||||||
|
Environment.GetEnvironmentVariable("DISCORDCHATEXPORTER_SETTINGS_PATH") is { } path
|
||||||
|
&& !string.IsNullOrWhiteSpace(path)
|
||||||
|
? Path.EndsInDirectorySeparator(path) || Directory.Exists(path)
|
||||||
|
? Path.Combine(path, "Settings.dat")
|
||||||
|
: path
|
||||||
|
: Path.Combine(AppContext.BaseDirectory, "Settings.dat"),
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user