dotnetsay: use stdin for message when redirected

This adds a feature to the dotnetsay program to allow using stdin as the message when stdin is redirected. This lets us do fun things like:

    fortune | dotnetsay
This commit is contained in:
David Lechner 2018-06-03 13:38:47 -05:00 committed by GitHub
parent 51c2ee17df
commit ed1c85de46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,7 +6,11 @@ public static class Program
{
string message = "Welcome to using a .NET Core global tool!";
if (args.Length > 0)
if (Console.IsInputRedirected)
{
message = Console.In.ReadToEnd();
}
else if (args.Length > 0)
{
message = String.Join(" ", args);
}
@ -59,4 +63,4 @@ public static class Program
return bot;
}
}
}