mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-02-14 15:53:30 -07:00
Warn about redirected streams in the CLI only when running inside Docker (#1176)
This commit is contained in:
parent
4e3deb409c
commit
a2c5d2e2dd
|
|
@ -4,6 +4,7 @@ using CliFx;
|
||||||
using CliFx.Attributes;
|
using CliFx.Attributes;
|
||||||
using CliFx.Infrastructure;
|
using CliFx.Infrastructure;
|
||||||
using DiscordChatExporter.Core.Discord;
|
using DiscordChatExporter.Core.Discord;
|
||||||
|
using DiscordChatExporter.Core.Utils;
|
||||||
|
|
||||||
namespace DiscordChatExporter.Cli.Commands.Base;
|
namespace DiscordChatExporter.Cli.Commands.Base;
|
||||||
|
|
||||||
|
|
@ -46,10 +47,10 @@ public abstract class DiscordCommandBase : ICommand
|
||||||
}
|
}
|
||||||
#pragma warning restore CS0618
|
#pragma warning restore CS0618
|
||||||
|
|
||||||
// Note about interactivity
|
// Note about interactivity for Docker
|
||||||
if (console.IsOutputRedirected)
|
if (console.IsOutputRedirected && Docker.IsRunningInDocker)
|
||||||
{
|
{
|
||||||
console.Output.WriteLine(
|
console.Error.WriteLine(
|
||||||
"Note: Output streams are redirected, rich console interactions are disabled. "
|
"Note: Output streams are redirected, rich console interactions are disabled. "
|
||||||
+ "If you are running this command in Docker, consider allocating a pseudo-terminal for better user experience (docker run -it ...)."
|
+ "If you are running this command in Docker, consider allocating a pseudo-terminal for better user experience (docker run -it ...)."
|
||||||
);
|
);
|
||||||
|
|
|
||||||
9
DiscordChatExporter.Core/Utils/Docker.cs
Normal file
9
DiscordChatExporter.Core/Utils/Docker.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace DiscordChatExporter.Core.Utils;
|
||||||
|
|
||||||
|
public static class Docker
|
||||||
|
{
|
||||||
|
public static bool IsRunningInDocker { get; } =
|
||||||
|
Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER") == "true";
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue