61 lines
2.2 KiB
C#
61 lines
2.2 KiB
C#
// <copyright file="ConfigCommandGroup.cs" company="StellaOps">
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
// Sprint: SPRINT_20260112_014_CLI_config_viewer (CLI-CONFIG-010, CLI-CONFIG-011)
|
|
// </copyright>
|
|
|
|
using System.CommandLine;
|
|
using StellaOps.Cli.Services;
|
|
|
|
namespace StellaOps.Cli.Commands;
|
|
|
|
/// <summary>
|
|
/// CLI commands for inspecting StellaOps configuration.
|
|
/// </summary>
|
|
internal static class ConfigCommandGroup
|
|
{
|
|
public static Command Create(IBackendOperationsClient client)
|
|
{
|
|
var configCommand = new Command("config", "Inspect StellaOps configuration");
|
|
|
|
// stella config list
|
|
var listCommand = new Command("list", "List all available configuration paths");
|
|
var categoryOption = new Option<string?>("--category", "-c")
|
|
{
|
|
Description = "Filter by category (e.g., policy, scanner, notifier)"
|
|
};
|
|
listCommand.AddOption(categoryOption);
|
|
listCommand.SetHandler(
|
|
async (string? category) => await CommandHandlers.Config.ListAsync(category),
|
|
categoryOption);
|
|
|
|
// stella config <path> show
|
|
var pathArgument = new Argument<string>("path")
|
|
{
|
|
Description = "Configuration path (e.g., policy.determinization, scanner.epss)"
|
|
};
|
|
var showCommand = new Command("show", "Show configuration for a specific path");
|
|
showCommand.AddArgument(pathArgument);
|
|
var formatOption = new Option<string>("--format", "-f")
|
|
{
|
|
Description = "Output format: table, json, yaml"
|
|
};
|
|
formatOption.SetDefaultValue("table");
|
|
var showSecretsOption = new Option<bool>("--show-secrets")
|
|
{
|
|
Description = "Show secret values (default: redacted)"
|
|
};
|
|
showSecretsOption.SetDefaultValue(false);
|
|
showCommand.AddOption(formatOption);
|
|
showCommand.AddOption(showSecretsOption);
|
|
showCommand.SetHandler(
|
|
async (string path, string format, bool showSecrets) =>
|
|
await CommandHandlers.Config.ShowAsync(client, path, format, showSecrets),
|
|
pathArgument, formatOption, showSecretsOption);
|
|
|
|
configCommand.AddCommand(listCommand);
|
|
configCommand.AddCommand(showCommand);
|
|
|
|
return configCommand;
|
|
}
|
|
}
|