feat: implement all CLI command groups (10 groups, 11 files)

This commit is contained in:
Joseph Doherty
2026-03-17 14:59:08 -04:00
parent d41e156fe4
commit 40f74e4a42
12 changed files with 862 additions and 1 deletions

View File

@@ -0,0 +1,43 @@
using System.CommandLine;
using System.CommandLine.Parsing;
using ScadaLink.Commons.Messages.Management;
namespace ScadaLink.CLI.Commands;
public static class HealthCommands
{
public static Command Build(Option<string> contactPointsOption, Option<string> formatOption)
{
var command = new Command("health") { Description = "Health monitoring" };
command.Add(BuildSummary(contactPointsOption, formatOption));
command.Add(BuildSite(contactPointsOption, formatOption));
return command;
}
private static Command BuildSummary(Option<string> contactPointsOption, Option<string> formatOption)
{
var cmd = new Command("summary") { Description = "Get system health summary" };
cmd.SetAction(async (ParseResult result) =>
{
return await CommandHelpers.ExecuteCommandAsync(
result, contactPointsOption, formatOption, new GetHealthSummaryCommand());
});
return cmd;
}
private static Command BuildSite(Option<string> contactPointsOption, Option<string> formatOption)
{
var identifierOption = new Option<string>("--identifier") { Description = "Site identifier", Required = true };
var cmd = new Command("site") { Description = "Get health for a specific site" };
cmd.Add(identifierOption);
cmd.SetAction(async (ParseResult result) =>
{
var identifier = result.GetValue(identifierOption)!;
return await CommandHelpers.ExecuteCommandAsync(
result, contactPointsOption, formatOption, new GetSiteHealthCommand(identifier));
});
return cmd;
}
}