49 lines
1.5 KiB
C#
49 lines
1.5 KiB
C#
using MxGateway.Client;
|
|
|
|
namespace MxGateway.Client.Cli;
|
|
|
|
public static class MxGatewayClientCli
|
|
{
|
|
public static int Run(
|
|
string[] args,
|
|
TextWriter standardOutput,
|
|
TextWriter standardError)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(args);
|
|
ArgumentNullException.ThrowIfNull(standardOutput);
|
|
ArgumentNullException.ThrowIfNull(standardError);
|
|
|
|
if (args.Length is 0 || IsHelp(args[0]))
|
|
{
|
|
WriteUsage(standardOutput);
|
|
return 0;
|
|
}
|
|
|
|
if (string.Equals(args[0], "version", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
standardOutput.WriteLine(
|
|
$"gateway-protocol={MxGatewayClientContractInfo.GatewayProtocolVersion}");
|
|
standardOutput.WriteLine(
|
|
$"worker-protocol={MxGatewayClientContractInfo.WorkerProtocolVersion}");
|
|
return 0;
|
|
}
|
|
|
|
standardError.WriteLine($"Unknown command '{args[0]}'.");
|
|
WriteUsage(standardError);
|
|
return 2;
|
|
}
|
|
|
|
private static bool IsHelp(string value)
|
|
{
|
|
return string.Equals(value, "-h", StringComparison.OrdinalIgnoreCase)
|
|
|| string.Equals(value, "--help", StringComparison.OrdinalIgnoreCase)
|
|
|| string.Equals(value, "help", StringComparison.OrdinalIgnoreCase);
|
|
}
|
|
|
|
private static void WriteUsage(TextWriter writer)
|
|
{
|
|
writer.WriteLine("mxgw-dotnet version");
|
|
writer.WriteLine("mxgw-dotnet --help");
|
|
}
|
|
}
|