more test commands
This commit is contained in:
parent
833bc2bd9c
commit
acd6edaa63
6 changed files with 126 additions and 7 deletions
|
@ -9,7 +9,6 @@ internal sealed class EchoStdinCommand : Command<EchoStdinCommand.Settings>
|
|||
public sealed class Settings : CommandSettings
|
||||
{
|
||||
[CommandOption("--target")] public OutputTarget Target { get; init; } = OutputTarget.StdOut;
|
||||
|
||||
[CommandOption("--length")] public long Length { get; init; } = long.MaxValue;
|
||||
}
|
||||
|
||||
|
@ -17,10 +16,10 @@ internal sealed class EchoStdinCommand : Command<EchoStdinCommand.Settings>
|
|||
{
|
||||
using var buffer = MemoryPool<char>.Shared.Rent(81920);
|
||||
|
||||
var totalBytesRead = 0L;
|
||||
while (totalBytesRead < settings.Length)
|
||||
var count = 0L;
|
||||
while (count < settings.Length)
|
||||
{
|
||||
var bytesWanted = (int)Math.Min(buffer.Memory.Length, settings.Length - totalBytesRead);
|
||||
var bytesWanted = (int)Math.Min(buffer.Memory.Length, settings.Length - count);
|
||||
|
||||
var bytesRead = Console.In.Read(buffer.Memory.Span[..bytesWanted]);
|
||||
if (bytesRead <= 0)
|
||||
|
@ -31,7 +30,7 @@ internal sealed class EchoStdinCommand : Command<EchoStdinCommand.Settings>
|
|||
writer.Write(buffer.Memory.Span[..bytesRead]);
|
||||
}
|
||||
|
||||
totalBytesRead += bytesRead;
|
||||
count += bytesRead;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue