From 795dfbb213ed1304155613ebaf311bfb301c9254 Mon Sep 17 00:00:00 2001 From: Alexey Golub Date: Thu, 11 Apr 2019 01:36:39 +0300 Subject: [PATCH] [CLI] Don't show 'completed' when export failed --- DiscordChatExporter.Cli/Internal/InlineProgress.cs | 9 ++++++++- DiscordChatExporter.Cli/Verbs/ExportChannelVerb.cs | 3 +++ .../Verbs/ExportDirectMessagesVerb.cs | 3 +++ DiscordChatExporter.Cli/Verbs/ExportGuildVerb.cs | 3 +++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/DiscordChatExporter.Cli/Internal/InlineProgress.cs b/DiscordChatExporter.Cli/Internal/InlineProgress.cs index c50d862..4d629d6 100644 --- a/DiscordChatExporter.Cli/Internal/InlineProgress.cs +++ b/DiscordChatExporter.Cli/Internal/InlineProgress.cs @@ -7,6 +7,8 @@ namespace DiscordChatExporter.Cli.Internal private readonly int _posX; private readonly int _posY; + private bool _isCompleted; + public InlineProgress() { // If output is not redirected - save initial cursor position @@ -27,6 +29,8 @@ namespace DiscordChatExporter.Cli.Internal } } + public void ReportCompletion() => _isCompleted = true; + public void Dispose() { // If output is not redirected - reset cursor position @@ -34,7 +38,10 @@ namespace DiscordChatExporter.Cli.Internal Console.SetCursorPosition(_posX, _posY); // Inform about completion - Console.WriteLine("Completed ✓"); + if (_isCompleted) + Console.WriteLine("Completed ✓"); + else + Console.WriteLine("Failed X"); } } } \ No newline at end of file diff --git a/DiscordChatExporter.Cli/Verbs/ExportChannelVerb.cs b/DiscordChatExporter.Cli/Verbs/ExportChannelVerb.cs index f407e68..00c7a36 100644 --- a/DiscordChatExporter.Cli/Verbs/ExportChannelVerb.cs +++ b/DiscordChatExporter.Cli/Verbs/ExportChannelVerb.cs @@ -49,6 +49,9 @@ namespace DiscordChatExporter.Cli.Verbs // Export await exportService.ExportChatLogAsync(chatLog, filePath, Options.ExportFormat, Options.PartitionLimit); + + // Report successful completion + progress.ReportCompletion(); } } } diff --git a/DiscordChatExporter.Cli/Verbs/ExportDirectMessagesVerb.cs b/DiscordChatExporter.Cli/Verbs/ExportDirectMessagesVerb.cs index 08fa301..61e8946 100644 --- a/DiscordChatExporter.Cli/Verbs/ExportDirectMessagesVerb.cs +++ b/DiscordChatExporter.Cli/Verbs/ExportDirectMessagesVerb.cs @@ -59,6 +59,9 @@ namespace DiscordChatExporter.Cli.Verbs // Export await exportService.ExportChatLogAsync(chatLog, filePath, Options.ExportFormat, Options.PartitionLimit); + + // Report successful completion + progress.ReportCompletion(); } } catch (HttpErrorStatusCodeException ex) when (ex.StatusCode == HttpStatusCode.Forbidden) diff --git a/DiscordChatExporter.Cli/Verbs/ExportGuildVerb.cs b/DiscordChatExporter.Cli/Verbs/ExportGuildVerb.cs index 454cdc1..c7eef82 100644 --- a/DiscordChatExporter.Cli/Verbs/ExportGuildVerb.cs +++ b/DiscordChatExporter.Cli/Verbs/ExportGuildVerb.cs @@ -60,6 +60,9 @@ namespace DiscordChatExporter.Cli.Verbs // Export await exportService.ExportChatLogAsync(chatLog, filePath, Options.ExportFormat, Options.PartitionLimit); + + // Report successful completion + progress.ReportCompletion(); } } catch (HttpErrorStatusCodeException ex) when (ex.StatusCode == HttpStatusCode.Forbidden)