CLI writing to error
This commit is contained in:
@@ -43,7 +43,7 @@ namespace AMWD.Protocols.Modbus.CliClient
|
|||||||
{
|
{
|
||||||
if (!ParseArguments(args))
|
if (!ParseArguments(args))
|
||||||
{
|
{
|
||||||
Console.WriteLine("Could not parse arguments.");
|
Console.Error.WriteLine("Could not parse arguments.");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,13 +55,13 @@ namespace AMWD.Protocols.Modbus.CliClient
|
|||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(_target))
|
if (string.IsNullOrWhiteSpace(_target))
|
||||||
{
|
{
|
||||||
Console.WriteLine("No serial port or tcp host specified.");
|
Console.Error.WriteLine("No serial port or tcp host specified.");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_typeOption.IsSet)
|
if (!_typeOption.IsSet)
|
||||||
{
|
{
|
||||||
Console.WriteLine("No type specified.");
|
Console.Error.WriteLine("No type specified.");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ namespace AMWD.Protocols.Modbus.CliClient
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Console.Write(".");
|
Console.Error.Write(".");
|
||||||
await Task.Delay(1000, cts.Token);
|
await Task.Delay(1000, cts.Token);
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException)
|
catch (OperationCanceledException)
|
||||||
@@ -87,7 +87,7 @@ namespace AMWD.Protocols.Modbus.CliClient
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Console.WriteLine();
|
Console.Error.WriteLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
using var client = CreateClient();
|
using var client = CreateClient();
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ namespace AMWD.Protocols.Modbus.CliProxy
|
|||||||
{
|
{
|
||||||
if (!ParseArguments(args))
|
if (!ParseArguments(args))
|
||||||
{
|
{
|
||||||
Console.WriteLine("Could not parse arguments.");
|
Console.Error.WriteLine("Could not parse arguments.");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ namespace AMWD.Protocols.Modbus.CliProxy
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Console.Write(".");
|
Console.Error.Write(".");
|
||||||
await Task.Delay(1000, cts.Token);
|
await Task.Delay(1000, cts.Token);
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException)
|
catch (OperationCanceledException)
|
||||||
@@ -89,12 +89,15 @@ namespace AMWD.Protocols.Modbus.CliProxy
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Console.WriteLine();
|
Console.Error.WriteLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var client = CreateClient();
|
using var client = CreateClient();
|
||||||
|
Console.WriteLine(client);
|
||||||
|
Console.WriteLine();
|
||||||
|
|
||||||
if (_clientProtocolOption.IsSet)
|
if (_clientProtocolOption.IsSet)
|
||||||
{
|
{
|
||||||
switch (_clientProtocolOption.Value.ToLower())
|
switch (_clientProtocolOption.Value.ToLower())
|
||||||
@@ -105,10 +108,13 @@ namespace AMWD.Protocols.Modbus.CliProxy
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
using var proxy = CreateProxy(client);
|
using var proxy = CreateProxy(client);
|
||||||
|
Console.WriteLine(proxy);
|
||||||
|
Console.WriteLine();
|
||||||
|
|
||||||
await proxy.StartAsync(cts.Token);
|
await proxy.StartAsync(cts.Token);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("Running proxy. Press Ctrl+C to stop.");
|
||||||
await Task.Delay(Timeout.Infinite, cts.Token);
|
await Task.Delay(Timeout.Infinite, cts.Token);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|||||||
Reference in New Issue
Block a user