diff --git a/cli/Squidex.CLI/Directory.Build.props b/cli/Squidex.CLI/Directory.Build.props index 9c492e71..855a3b38 100644 --- a/cli/Squidex.CLI/Directory.Build.props +++ b/cli/Squidex.CLI/Directory.Build.props @@ -8,6 +8,6 @@ MIT https://github.com/Squidex/squidex/ Squidex HeadlessCMS - 8.11 + 8.12 diff --git a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/ConsoleLogger.cs b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/ConsoleLogger.cs index ccba3280..9d822ee4 100644 --- a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/ConsoleLogger.cs +++ b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/ConsoleLogger.cs @@ -15,9 +15,18 @@ private sealed class ConsoleLine : ILogLine { private readonly int consoleTop; + public bool CanWriteToSameLine => consoleTop >= 0; + public ConsoleLine() { - consoleTop = Console.CursorTop; + try + { + consoleTop = Console.CursorTop; + } + catch + { + consoleTop = -1; + } } public void Dispose() @@ -27,7 +36,11 @@ public void Dispose() public void WriteLine(string message, params object[] args) { Console.WriteLine(message, args); - Console.SetCursorPosition(0, consoleTop); + + if (consoleTop >= 0) + { + Console.SetCursorPosition(0, consoleTop); + } } } diff --git a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/ILogLine.cs b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/ILogLine.cs index c60086fc..c1fdc3fc 100644 --- a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/ILogLine.cs +++ b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/ILogLine.cs @@ -9,6 +9,8 @@ namespace Squidex.CLI.Commands.Implementation { public interface ILogLine : IDisposable { + bool CanWriteToSameLine { get; } + void WriteLine(string message, params object[] args); } } diff --git a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/ImExport/ExportHelper.cs b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/ImExport/ExportHelper.cs index dbc7fdc9..40e69e6d 100644 --- a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/ImExport/ExportHelper.cs +++ b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/ImExport/ExportHelper.cs @@ -53,7 +53,10 @@ public static async Task ExportAsync(this ISession session, IExportSettings sett await handler(entity); - logLine.WriteLine("> Exported: {0} of {1}.", totalRead, total); + if (logLine.CanWriteToSameLine) + { + logLine.WriteLine("> Exported: {0} of {1}.", totalRead, total); + } } } diff --git a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/ImExport/ImportHelper.cs b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/ImExport/ImportHelper.cs index 33ab30ed..5c9491e8 100644 --- a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/ImExport/ImportHelper.cs +++ b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/ImExport/ImportHelper.cs @@ -87,7 +87,10 @@ public static async Task ImportAsync(this ISession session, IImportSettings sett totalWritten += update.Jobs.Count; - logLine.WriteLine("> Imported: {0}.", totalWritten); + if (logLine.CanWriteToSameLine) + { + logLine.WriteLine("> Imported: {0}.", totalWritten); + } } }