diff --git a/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs b/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs index 54167ffe..56123915 100644 --- a/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs +++ b/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs @@ -147,12 +147,10 @@ public abstract class ExportCommandBase : DiscordCommandBase var isValidOutputPath = // Anything is valid when exporting a single channel channels.Count <= 1 - || // When using template tokens, assume the user knows what they're doing - OutputPath.Contains('%') - || + || OutputPath.Contains('%') // Otherwise, require an existing directory or an unambiguous directory path - Directory.Exists(OutputPath) + || Directory.Exists(OutputPath) || PathEx.IsDirectoryPath(OutputPath); if (!isValidOutputPath) diff --git a/DiscordChatExporter.Cli/Commands/Converters/ThreadInclusionBindingConverter.cs b/DiscordChatExporter.Cli/Commands/Converters/ThreadInclusionModeBindingConverter.cs similarity index 58% rename from DiscordChatExporter.Cli/Commands/Converters/ThreadInclusionBindingConverter.cs rename to DiscordChatExporter.Cli/Commands/Converters/ThreadInclusionModeBindingConverter.cs index 0466e655..7857024f 100644 --- a/DiscordChatExporter.Cli/Commands/Converters/ThreadInclusionBindingConverter.cs +++ b/DiscordChatExporter.Cli/Commands/Converters/ThreadInclusionModeBindingConverter.cs @@ -4,19 +4,19 @@ using DiscordChatExporter.Cli.Commands.Shared; namespace DiscordChatExporter.Cli.Commands.Converters; -internal class ThreadInclusionBindingConverter : BindingConverter +internal class ThreadInclusionModeBindingConverter : BindingConverter { - public override ThreadInclusion Convert(string? rawValue) + public override ThreadInclusionMode Convert(string? rawValue) { // Empty or unset value is treated as 'active' to match the previous behavior if (string.IsNullOrWhiteSpace(rawValue)) - return ThreadInclusion.Active; + return ThreadInclusionMode.Active; // Boolean 'true' is treated as 'active', boolean 'false' is treated as 'none' if (bool.TryParse(rawValue, out var boolValue)) - return boolValue ? ThreadInclusion.Active : ThreadInclusion.None; + return boolValue ? ThreadInclusionMode.Active : ThreadInclusionMode.None; // Otherwise, fall back to regular enum parsing - return Enum.Parse(rawValue, true); + return Enum.Parse(rawValue, true); } } diff --git a/DiscordChatExporter.Cli/Commands/ExportAllCommand.cs b/DiscordChatExporter.Cli/Commands/ExportAllCommand.cs index 5a5cc0b3..0d4df038 100644 --- a/DiscordChatExporter.Cli/Commands/ExportAllCommand.cs +++ b/DiscordChatExporter.Cli/Commands/ExportAllCommand.cs @@ -30,9 +30,9 @@ public class ExportAllCommand : ExportCommandBase [CommandOption( "include-threads", Description = "Which types of threads should be included.", - Converter = typeof(ThreadInclusionBindingConverter) + Converter = typeof(ThreadInclusionModeBindingConverter) )] - public ThreadInclusion ThreadInclusion { get; init; } = ThreadInclusion.None; + public ThreadInclusionMode ThreadInclusionMode { get; init; } = ThreadInclusionMode.None; [CommandOption( "data-package", @@ -70,12 +70,12 @@ public class ExportAllCommand : ExportCommandBase } // Threads - if (ThreadInclusion != ThreadInclusion.None) + if (ThreadInclusionMode != ThreadInclusionMode.None) { await foreach ( var thread in Discord.GetGuildThreadsAsync( guild.Id, - ThreadInclusion == ThreadInclusion.All, + ThreadInclusionMode == ThreadInclusionMode.All, cancellationToken ) ) @@ -132,9 +132,9 @@ public class ExportAllCommand : ExportCommandBase channels.RemoveAll(c => c.Kind.IsGuild()); if (!IncludeVoiceChannels) channels.RemoveAll(c => c.Kind.IsVoice()); - if (ThreadInclusion == ThreadInclusion.None) + if (ThreadInclusionMode == ThreadInclusionMode.None) channels.RemoveAll(c => c.Kind.IsThread()); - if (ThreadInclusion != ThreadInclusion.All) + if (ThreadInclusionMode != ThreadInclusionMode.All) channels.RemoveAll(c => c.Kind.IsThread() && c.IsArchived); await ExportAsync(console, channels); diff --git a/DiscordChatExporter.Cli/Commands/ExportGuildCommand.cs b/DiscordChatExporter.Cli/Commands/ExportGuildCommand.cs index 20ad0f0d..38f55c2c 100644 --- a/DiscordChatExporter.Cli/Commands/ExportGuildCommand.cs +++ b/DiscordChatExporter.Cli/Commands/ExportGuildCommand.cs @@ -22,9 +22,9 @@ public class ExportGuildCommand : ExportCommandBase [CommandOption( "include-threads", Description = "Which types of threads should be included.", - Converter = typeof(ThreadInclusionBindingConverter) + Converter = typeof(ThreadInclusionModeBindingConverter) )] - public ThreadInclusion ThreadInclusion { get; init; } = ThreadInclusion.None; + public ThreadInclusionMode ThreadInclusionMode { get; init; } = ThreadInclusionMode.None; public override async ValueTask ExecuteAsync(IConsole console) { @@ -48,12 +48,12 @@ public class ExportGuildCommand : ExportCommandBase } // Threads - if (ThreadInclusion != ThreadInclusion.None) + if (ThreadInclusionMode != ThreadInclusionMode.None) { await foreach ( var thread in Discord.GetGuildThreadsAsync( GuildId, - ThreadInclusion == ThreadInclusion.All, + ThreadInclusionMode == ThreadInclusionMode.All, cancellationToken ) ) diff --git a/DiscordChatExporter.Cli/Commands/GetChannelsCommand.cs b/DiscordChatExporter.Cli/Commands/GetChannelsCommand.cs index f74ca35a..178b4d6f 100644 --- a/DiscordChatExporter.Cli/Commands/GetChannelsCommand.cs +++ b/DiscordChatExporter.Cli/Commands/GetChannelsCommand.cs @@ -24,9 +24,9 @@ public class GetChannelsCommand : DiscordCommandBase [CommandOption( "include-threads", Description = "Which types of threads should be included.", - Converter = typeof(ThreadInclusionBindingConverter) + Converter = typeof(ThreadInclusionModeBindingConverter) )] - public ThreadInclusion ThreadInclusion { get; init; } = ThreadInclusion.None; + public ThreadInclusionMode ThreadInclusionMode { get; init; } = ThreadInclusionMode.None; public override async ValueTask ExecuteAsync(IConsole console) { @@ -47,11 +47,11 @@ public class GetChannelsCommand : DiscordCommandBase .FirstOrDefault(); var threads = - ThreadInclusion != ThreadInclusion.None + ThreadInclusionMode != ThreadInclusionMode.None ? ( await Discord.GetGuildThreadsAsync( GuildId, - ThreadInclusion == ThreadInclusion.All, + ThreadInclusionMode == ThreadInclusionMode.All, cancellationToken ) ) diff --git a/DiscordChatExporter.Cli/Commands/Shared/ThreadInclusion.cs b/DiscordChatExporter.Cli/Commands/Shared/ThreadInclusionMode.cs similarity index 73% rename from DiscordChatExporter.Cli/Commands/Shared/ThreadInclusion.cs rename to DiscordChatExporter.Cli/Commands/Shared/ThreadInclusionMode.cs index afe201ac..878cdff6 100644 --- a/DiscordChatExporter.Cli/Commands/Shared/ThreadInclusion.cs +++ b/DiscordChatExporter.Cli/Commands/Shared/ThreadInclusionMode.cs @@ -1,6 +1,6 @@ namespace DiscordChatExporter.Cli.Commands.Shared; -public enum ThreadInclusion +public enum ThreadInclusionMode { None, Active, diff --git a/DiscordChatExporter.Gui/Models/ThreadInclusion.cs b/DiscordChatExporter.Gui/Models/ThreadInclusionMode.cs similarity index 71% rename from DiscordChatExporter.Gui/Models/ThreadInclusion.cs rename to DiscordChatExporter.Gui/Models/ThreadInclusionMode.cs index 98bc6d78..41e21628 100644 --- a/DiscordChatExporter.Gui/Models/ThreadInclusion.cs +++ b/DiscordChatExporter.Gui/Models/ThreadInclusionMode.cs @@ -1,6 +1,6 @@ namespace DiscordChatExporter.Gui.Models; -public enum ThreadInclusion +public enum ThreadInclusionMode { None, Active, diff --git a/DiscordChatExporter.Gui/Services/SettingsService.cs b/DiscordChatExporter.Gui/Services/SettingsService.cs index ba201134..6662b410 100644 --- a/DiscordChatExporter.Gui/Services/SettingsService.cs +++ b/DiscordChatExporter.Gui/Services/SettingsService.cs @@ -17,7 +17,7 @@ public partial class SettingsService : SettingsBase public bool IsTokenPersisted { get; set; } = true; - public ThreadInclusion ThreadInclusion { get; set; } = ThreadInclusion.None; + public ThreadInclusionMode ThreadInclusionMode { get; set; } = ThreadInclusionMode.None; public string DateFormat { get; set; } = "MM/dd/yyyy h:mm tt"; diff --git a/DiscordChatExporter.Gui/ViewModels/Components/DashboardViewModel.cs b/DiscordChatExporter.Gui/ViewModels/Components/DashboardViewModel.cs index e6e660f1..8cd12177 100644 --- a/DiscordChatExporter.Gui/ViewModels/Components/DashboardViewModel.cs +++ b/DiscordChatExporter.Gui/ViewModels/Components/DashboardViewModel.cs @@ -170,12 +170,12 @@ public class DashboardViewModel : PropertyChangedBase } // Threads - if (_settingsService.ThreadInclusion != ThreadInclusion.None) + if (_settingsService.ThreadInclusionMode != ThreadInclusionMode.None) { await foreach ( var thread in _discord.GetGuildThreadsAsync( SelectedGuild.Id, - _settingsService.ThreadInclusion == ThreadInclusion.All + _settingsService.ThreadInclusionMode == ThreadInclusionMode.All ) ) { diff --git a/DiscordChatExporter.Gui/ViewModels/Dialogs/SettingsViewModel.cs b/DiscordChatExporter.Gui/ViewModels/Dialogs/SettingsViewModel.cs index 2ab0d820..0d22736c 100644 --- a/DiscordChatExporter.Gui/ViewModels/Dialogs/SettingsViewModel.cs +++ b/DiscordChatExporter.Gui/ViewModels/Dialogs/SettingsViewModel.cs @@ -28,13 +28,13 @@ public class SettingsViewModel : DialogScreen set => _settingsService.IsTokenPersisted = value; } - public IReadOnlyList AvailableThreadInclusions { get; } = - Enum.GetValues(); + public IReadOnlyList AvailableThreadInclusions { get; } = + Enum.GetValues(); - public ThreadInclusion ThreadInclusion + public ThreadInclusionMode ThreadInclusionMode { - get => _settingsService.ThreadInclusion; - set => _settingsService.ThreadInclusion = value; + get => _settingsService.ThreadInclusionMode; + set => _settingsService.ThreadInclusionMode = value; } public string DateFormat diff --git a/DiscordChatExporter.Gui/Views/Dialogs/SettingsView.xaml b/DiscordChatExporter.Gui/Views/Dialogs/SettingsView.xaml index 45a7b7a8..ced29e9e 100644 --- a/DiscordChatExporter.Gui/Views/Dialogs/SettingsView.xaml +++ b/DiscordChatExporter.Gui/Views/Dialogs/SettingsView.xaml @@ -82,7 +82,7 @@ IsChecked="{Binding IsTokenPersisted}" /> - + + SelectedItem="{Binding ThreadInclusionMode}" />