From b298b45cf7963ec282183f72d09c4cfaeada3438 Mon Sep 17 00:00:00 2001 From: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> Date: Fri, 13 Oct 2023 01:17:13 +0300 Subject: [PATCH] Escape markup in CLI --- .../Commands/Base/ExportCommandBase.cs | 2 +- .../Commands/ExportAllCommand.cs | 16 +++++++++++++--- .../Commands/ExportGuildCommand.cs | 6 ++++-- .../Utils/Extensions/ConsoleExtensions.cs | 3 +-- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs b/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs index 87e0b258..39e61197 100644 --- a/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs +++ b/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs @@ -200,7 +200,7 @@ public abstract class ExportCommandBase : DiscordCommandBase try { await ctx.StartTaskAsync( - channel.GetHierarchicalName(), + Markup.Escape(channel.GetHierarchicalName()), async progress => { var guild = await Discord.GetGuildAsync( diff --git a/DiscordChatExporter.Cli/Commands/ExportAllCommand.cs b/DiscordChatExporter.Cli/Commands/ExportAllCommand.cs index 7d6393ff..12335a17 100644 --- a/DiscordChatExporter.Cli/Commands/ExportAllCommand.cs +++ b/DiscordChatExporter.Cli/Commands/ExportAllCommand.cs @@ -80,7 +80,10 @@ public class ExportAllCommand : ExportCommandBase channels.Add(channel); - ctx.Status($"Fetched '{channel.GetHierarchicalName()}'."); + ctx.Status( + Markup.Escape($"Fetched '{channel.GetHierarchicalName()}'.") + ); + fetchedChannelsCount++; } } @@ -114,7 +117,10 @@ public class ExportAllCommand : ExportCommandBase { channels.Add(thread); - ctx.Status($"Fetched '{thread.GetHierarchicalName()}'."); + ctx.Status( + Markup.Escape($"Fetched '{thread.GetHierarchicalName()}'.") + ); + fetchedThreadsCount++; } } @@ -142,7 +148,11 @@ public class ExportAllCommand : ExportCommandBase { foreach (var dumpChannel in dump.Channels) { - ctx.Status($"Fetching '{dumpChannel.Name}' ({dumpChannel.Id})..."); + ctx.Status( + Markup.Escape( + $"Fetching '{dumpChannel.Name}' ({dumpChannel.Id})..." + ) + ); try { diff --git a/DiscordChatExporter.Cli/Commands/ExportGuildCommand.cs b/DiscordChatExporter.Cli/Commands/ExportGuildCommand.cs index c9e6088d..24e41ad5 100644 --- a/DiscordChatExporter.Cli/Commands/ExportGuildCommand.cs +++ b/DiscordChatExporter.Cli/Commands/ExportGuildCommand.cs @@ -58,7 +58,8 @@ public class ExportGuildCommand : ExportCommandBase channels.Add(channel); - ctx.Status($"Fetched '{channel.GetHierarchicalName()}'."); + ctx.Status(Markup.Escape($"Fetched '{channel.GetHierarchicalName()}'.")); + fetchedChannelsCount++; } } @@ -90,7 +91,8 @@ public class ExportGuildCommand : ExportCommandBase { channels.Add(thread); - ctx.Status($"Fetched '{thread.GetHierarchicalName()}'."); + ctx.Status(Markup.Escape($"Fetched '{thread.GetHierarchicalName()}'.")); + fetchedThreadsCount++; } } diff --git a/DiscordChatExporter.Cli/Utils/Extensions/ConsoleExtensions.cs b/DiscordChatExporter.Cli/Utils/Extensions/ConsoleExtensions.cs index 345fb811..239de801 100644 --- a/DiscordChatExporter.Cli/Utils/Extensions/ConsoleExtensions.cs +++ b/DiscordChatExporter.Cli/Utils/Extensions/ConsoleExtensions.cs @@ -44,8 +44,7 @@ internal static class ConsoleExtensions var actualDescription = !string.IsNullOrWhiteSpace(description) ? description : "..."; var progressTask = context.AddTask( - // Don't recognize random square brackets as style tags - Markup.Escape(actualDescription), + actualDescription, new ProgressTaskSettings { MaxValue = 1 } );