From 9f9274b3524fc143736aa26098f7bfdff2548b6a Mon Sep 17 00:00:00 2001 From: tyrrrz <1935960+Tyrrrz@users.noreply.github.com> Date: Thu, 26 Mar 2026 21:31:40 +0200 Subject: [PATCH] Migrate to CliFx v3 --- Directory.Packages.props | 7 ++-- .../Commands/Base/DiscordCommandBase.cs | 2 +- .../Commands/Base/ExportCommandBase.cs | 4 +-- .../ThreadInclusionModeBindingConverter.cs | 4 +-- .../TruthyBooleanBindingConverter.cs | 4 +-- .../Commands/ExportAllCommand.cs | 2 +- .../Commands/ExportChannelsCommand.cs | 2 +- .../Commands/ExportDirectMessagesCommand.cs | 2 +- .../Commands/ExportGuildCommand.cs | 2 +- .../Commands/GetChannelsCommand.cs | 2 +- .../Commands/GetDirectChannelsCommand.cs | 2 +- .../Commands/GetGuildsCommand.cs | 2 +- .../Commands/GuideCommand.cs | 2 +- .../DiscordChatExporter.Cli.csproj | 6 ---- DiscordChatExporter.Cli/Program.cs | 34 ++----------------- .../DiscordChatExporter.Gui.csproj | 6 ---- .../PublishMacOSBundle.csx | 2 +- 17 files changed, 24 insertions(+), 61 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index ebbc7454..868e90c2 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -10,7 +10,7 @@ - + @@ -26,7 +26,10 @@ - + diff --git a/DiscordChatExporter.Cli/Commands/Base/DiscordCommandBase.cs b/DiscordChatExporter.Cli/Commands/Base/DiscordCommandBase.cs index 049d573a..33344079 100644 --- a/DiscordChatExporter.Cli/Commands/Base/DiscordCommandBase.cs +++ b/DiscordChatExporter.Cli/Commands/Base/DiscordCommandBase.cs @@ -2,7 +2,7 @@ using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; using CliFx; -using CliFx.Attributes; +using CliFx.Binding; using CliFx.Infrastructure; using DiscordChatExporter.Core.Discord; using DiscordChatExporter.Core.Utils; diff --git a/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs b/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs index 070c8e88..b2bcf6f9 100644 --- a/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs +++ b/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs @@ -5,8 +5,8 @@ using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Threading.Tasks; -using CliFx.Attributes; -using CliFx.Exceptions; +using CliFx; +using CliFx.Binding; using CliFx.Infrastructure; using DiscordChatExporter.Cli.Commands.Converters; using DiscordChatExporter.Cli.Commands.Shared; diff --git a/DiscordChatExporter.Cli/Commands/Converters/ThreadInclusionModeBindingConverter.cs b/DiscordChatExporter.Cli/Commands/Converters/ThreadInclusionModeBindingConverter.cs index 7857024f..8a4a385f 100644 --- a/DiscordChatExporter.Cli/Commands/Converters/ThreadInclusionModeBindingConverter.cs +++ b/DiscordChatExporter.Cli/Commands/Converters/ThreadInclusionModeBindingConverter.cs @@ -1,10 +1,10 @@ using System; -using CliFx.Extensibility; +using CliFx.Activation; using DiscordChatExporter.Cli.Commands.Shared; namespace DiscordChatExporter.Cli.Commands.Converters; -internal class ThreadInclusionModeBindingConverter : BindingConverter +internal class ThreadInclusionModeBindingConverter : ScalarInputConverter { public override ThreadInclusionMode Convert(string? rawValue) { diff --git a/DiscordChatExporter.Cli/Commands/Converters/TruthyBooleanBindingConverter.cs b/DiscordChatExporter.Cli/Commands/Converters/TruthyBooleanBindingConverter.cs index 5f4abd20..23ebd1fb 100644 --- a/DiscordChatExporter.Cli/Commands/Converters/TruthyBooleanBindingConverter.cs +++ b/DiscordChatExporter.Cli/Commands/Converters/TruthyBooleanBindingConverter.cs @@ -1,9 +1,9 @@ using System.Globalization; -using CliFx.Extensibility; +using CliFx.Activation; namespace DiscordChatExporter.Cli.Commands.Converters; -internal class TruthyBooleanBindingConverter : BindingConverter +internal class TruthyBooleanBindingConverter : ScalarInputConverter { public override bool Convert(string? rawValue) { diff --git a/DiscordChatExporter.Cli/Commands/ExportAllCommand.cs b/DiscordChatExporter.Cli/Commands/ExportAllCommand.cs index 5d156e84..6228af1c 100644 --- a/DiscordChatExporter.Cli/Commands/ExportAllCommand.cs +++ b/DiscordChatExporter.Cli/Commands/ExportAllCommand.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using CliFx.Attributes; +using CliFx.Binding; using CliFx.Infrastructure; using DiscordChatExporter.Cli.Commands.Base; using DiscordChatExporter.Cli.Utils.Extensions; diff --git a/DiscordChatExporter.Cli/Commands/ExportChannelsCommand.cs b/DiscordChatExporter.Cli/Commands/ExportChannelsCommand.cs index a0e1e94c..4150fbb0 100644 --- a/DiscordChatExporter.Cli/Commands/ExportChannelsCommand.cs +++ b/DiscordChatExporter.Cli/Commands/ExportChannelsCommand.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; using System.Threading.Tasks; -using CliFx.Attributes; +using CliFx.Binding; using CliFx.Infrastructure; using DiscordChatExporter.Cli.Commands.Base; using DiscordChatExporter.Core.Discord; diff --git a/DiscordChatExporter.Cli/Commands/ExportDirectMessagesCommand.cs b/DiscordChatExporter.Cli/Commands/ExportDirectMessagesCommand.cs index 69c80f79..77f9e665 100644 --- a/DiscordChatExporter.Cli/Commands/ExportDirectMessagesCommand.cs +++ b/DiscordChatExporter.Cli/Commands/ExportDirectMessagesCommand.cs @@ -1,5 +1,5 @@ using System.Threading.Tasks; -using CliFx.Attributes; +using CliFx.Binding; using CliFx.Infrastructure; using DiscordChatExporter.Cli.Commands.Base; using DiscordChatExporter.Core.Discord.Data; diff --git a/DiscordChatExporter.Cli/Commands/ExportGuildCommand.cs b/DiscordChatExporter.Cli/Commands/ExportGuildCommand.cs index 90eb3d79..ab69acc9 100644 --- a/DiscordChatExporter.Cli/Commands/ExportGuildCommand.cs +++ b/DiscordChatExporter.Cli/Commands/ExportGuildCommand.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; using System.Threading.Tasks; -using CliFx.Attributes; +using CliFx.Binding; using CliFx.Infrastructure; using DiscordChatExporter.Cli.Commands.Base; using DiscordChatExporter.Cli.Utils.Extensions; diff --git a/DiscordChatExporter.Cli/Commands/GetChannelsCommand.cs b/DiscordChatExporter.Cli/Commands/GetChannelsCommand.cs index 60b152fe..978d5e79 100644 --- a/DiscordChatExporter.Cli/Commands/GetChannelsCommand.cs +++ b/DiscordChatExporter.Cli/Commands/GetChannelsCommand.cs @@ -1,7 +1,7 @@ using System; using System.Linq; using System.Threading.Tasks; -using CliFx.Attributes; +using CliFx.Binding; using CliFx.Infrastructure; using DiscordChatExporter.Cli.Commands.Base; using DiscordChatExporter.Cli.Commands.Converters; diff --git a/DiscordChatExporter.Cli/Commands/GetDirectChannelsCommand.cs b/DiscordChatExporter.Cli/Commands/GetDirectChannelsCommand.cs index daedf096..00338c18 100644 --- a/DiscordChatExporter.Cli/Commands/GetDirectChannelsCommand.cs +++ b/DiscordChatExporter.Cli/Commands/GetDirectChannelsCommand.cs @@ -1,7 +1,7 @@ using System; using System.Linq; using System.Threading.Tasks; -using CliFx.Attributes; +using CliFx.Binding; using CliFx.Infrastructure; using DiscordChatExporter.Cli.Commands.Base; using DiscordChatExporter.Core.Discord.Data; diff --git a/DiscordChatExporter.Cli/Commands/GetGuildsCommand.cs b/DiscordChatExporter.Cli/Commands/GetGuildsCommand.cs index 42642c41..59f3e807 100644 --- a/DiscordChatExporter.Cli/Commands/GetGuildsCommand.cs +++ b/DiscordChatExporter.Cli/Commands/GetGuildsCommand.cs @@ -1,7 +1,7 @@ using System; using System.Linq; using System.Threading.Tasks; -using CliFx.Attributes; +using CliFx.Binding; using CliFx.Infrastructure; using DiscordChatExporter.Cli.Commands.Base; using DiscordChatExporter.Core.Discord.Data; diff --git a/DiscordChatExporter.Cli/Commands/GuideCommand.cs b/DiscordChatExporter.Cli/Commands/GuideCommand.cs index f4bd09cf..529e692e 100644 --- a/DiscordChatExporter.Cli/Commands/GuideCommand.cs +++ b/DiscordChatExporter.Cli/Commands/GuideCommand.cs @@ -1,7 +1,7 @@ using System; using System.Threading.Tasks; using CliFx; -using CliFx.Attributes; +using CliFx.Binding; using CliFx.Infrastructure; namespace DiscordChatExporter.Cli.Commands; diff --git a/DiscordChatExporter.Cli/DiscordChatExporter.Cli.csproj b/DiscordChatExporter.Cli/DiscordChatExporter.Cli.csproj index 6317bcca..9e4b02c8 100644 --- a/DiscordChatExporter.Cli/DiscordChatExporter.Cli.csproj +++ b/DiscordChatExporter.Cli/DiscordChatExporter.Cli.csproj @@ -6,12 +6,6 @@ false - - - false - false - - diff --git a/DiscordChatExporter.Cli/Program.cs b/DiscordChatExporter.Cli/Program.cs index 2dfa24ba..776d2e0b 100644 --- a/DiscordChatExporter.Cli/Program.cs +++ b/DiscordChatExporter.Cli/Program.cs @@ -1,41 +1,13 @@ -using System.Diagnostics.CodeAnalysis; -using System.Threading.Tasks; +using System.Threading.Tasks; using CliFx; -using DiscordChatExporter.Cli.Commands; -using DiscordChatExporter.Cli.Commands.Converters; -using DiscordChatExporter.Core.Exporting.Filtering; -using DiscordChatExporter.Core.Exporting.Partitioning; namespace DiscordChatExporter.Cli; public static class Program { - // Explicit references because CliFx relies on reflection and we're publishing with trimming enabled - [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ExportAllCommand))] - [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ExportChannelsCommand))] - [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ExportDirectMessagesCommand))] - [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ExportGuildCommand))] - [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(GetChannelsCommand))] - [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(GetDirectChannelsCommand))] - [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(GetGuildsCommand))] - [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(GuideCommand))] - [DynamicDependency( - DynamicallyAccessedMemberTypes.All, - typeof(ThreadInclusionModeBindingConverter) - )] - [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(TruthyBooleanBindingConverter))] - [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(PartitionLimit))] - [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(MessageFilter))] public static async Task Main(string[] args) => - await new CliApplicationBuilder() - .AddCommand() - .AddCommand() - .AddCommand() - .AddCommand() - .AddCommand() - .AddCommand() - .AddCommand() - .AddCommand() + await new CommandLineApplicationBuilder() + .AddCommandsFromThisAssembly() .Build() .RunAsync(args); } diff --git a/DiscordChatExporter.Gui/DiscordChatExporter.Gui.csproj b/DiscordChatExporter.Gui/DiscordChatExporter.Gui.csproj index b8950ea5..a35c363c 100644 --- a/DiscordChatExporter.Gui/DiscordChatExporter.Gui.csproj +++ b/DiscordChatExporter.Gui/DiscordChatExporter.Gui.csproj @@ -21,12 +21,6 @@ false - - - false - false - - diff --git a/DiscordChatExporter.Gui/PublishMacOSBundle.csx b/DiscordChatExporter.Gui/PublishMacOSBundle.csx index 080d5f24..1683d5bf 100755 --- a/DiscordChatExporter.Gui/PublishMacOSBundle.csx +++ b/DiscordChatExporter.Gui/PublishMacOSBundle.csx @@ -2,7 +2,7 @@ #:package CliFx using CliFx; -using CliFx.Attributes; +using CliFx.Binding; using CliFx.Infrastructure; return await new CliApplicationBuilder()