Files
Omika/tools/Omika.HfSqlProbe/ProbeArgumentParser.cs
T
2026-10-23 18:46:50 +02:00

44 lines
1.7 KiB
C#

namespace Omika.HfSqlProbe;
internal static class ProbeArgumentParser
{
public static ProbeOptions Parse(ReadOnlySpan<string> args)
{
var options = new ProbeOptions();
for (int i = 0; i < args.Length; i++)
{
string arg = args[i];
if (arg == "--connection-string" && i + 1 < args.Length)
options.ConnectionString = args[++i];
else if (arg == "--allow-write-probe")
options.AllowWriteProbe = true;
else if (arg == "--table" && i + 1 < args.Length)
options.Table = args[++i];
else if (arg == "--id-column" && i + 1 < args.Length)
options.IdColumn = args[++i];
else if (arg == "--marker-column" && i + 1 < args.Length)
options.MarkerColumn = args[++i];
else if (arg == "--schema" && i + 1 < args.Length)
options.Schema = args[++i];
else if (arg == "--database-name" && i + 1 < args.Length)
options.DatabaseName = args[++i];
else if (arg == "--use-client-table")
options.UseClientTable = true;
}
return options;
}
public static string NormalizeCommand(ReadOnlySpan<string> args)
{
if (args.Length == 0) return "";
return args[0].ToLowerInvariant();
}
public static bool IsWriteCommand(string command)
=> command is "transaction" or "returning" or "client-insert" or "client-graph";
public static bool IsValidCommand(string command)
=> command is "capabilities" or "audit" or "transaction" or "returning" or "omika-guid"
or "client-insert" or "client-graph" or "table-exists" or "protected-access" or "--help";
}