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:
parent
51c2ee17df
commit
ed1c85de46
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue