up
Some checks failed
AOC Guard CI / aoc-guard (push) Has been cancelled
AOC Guard CI / aoc-verify (push) Has been cancelled
Concelier Attestation Tests / attestation-tests (push) Has been cancelled
Docs CI / lint-and-preview (push) Has been cancelled
Policy Lint & Smoke / policy-lint (push) Has been cancelled
devportal-offline / build-offline (push) Has been cancelled
Mirror Thin Bundle Sign & Verify / mirror-sign (push) Has been cancelled
Some checks failed
AOC Guard CI / aoc-guard (push) Has been cancelled
AOC Guard CI / aoc-verify (push) Has been cancelled
Concelier Attestation Tests / attestation-tests (push) Has been cancelled
Docs CI / lint-and-preview (push) Has been cancelled
Policy Lint & Smoke / policy-lint (push) Has been cancelled
devportal-offline / build-offline (push) Has been cancelled
Mirror Thin Bundle Sign & Verify / mirror-sign (push) Has been cancelled
This commit is contained in:
@@ -24,11 +24,17 @@ internal static class CommandFactory
|
||||
Description = "Enable verbose logging output."
|
||||
};
|
||||
|
||||
var globalTenantOption = new Option<string?>("--tenant", new[] { "-t" })
|
||||
{
|
||||
Description = "Tenant context for the operation. Overrides profile and STELLAOPS_TENANT environment variable."
|
||||
};
|
||||
|
||||
var root = new RootCommand("StellaOps command-line interface")
|
||||
{
|
||||
TreatUnmatchedTokensAsErrors = true
|
||||
};
|
||||
root.Add(verboseOption);
|
||||
root.Add(globalTenantOption);
|
||||
|
||||
root.Add(BuildScannerCommand(services, verboseOption, cancellationToken));
|
||||
root.Add(BuildScanCommand(services, options, verboseOption, cancellationToken));
|
||||
@@ -38,6 +44,7 @@ internal static class CommandFactory
|
||||
root.Add(BuildSourcesCommand(services, verboseOption, cancellationToken));
|
||||
root.Add(BuildAocCommand(services, verboseOption, cancellationToken));
|
||||
root.Add(BuildAuthCommand(services, options, verboseOption, cancellationToken));
|
||||
root.Add(BuildTenantsCommand(services, options, verboseOption, cancellationToken));
|
||||
root.Add(BuildPolicyCommand(services, options, verboseOption, cancellationToken));
|
||||
root.Add(BuildTaskRunnerCommand(services, verboseOption, cancellationToken));
|
||||
root.Add(BuildFindingsCommand(services, verboseOption, cancellationToken));
|
||||
@@ -772,6 +779,74 @@ internal static class CommandFactory
|
||||
return auth;
|
||||
}
|
||||
|
||||
private static Command BuildTenantsCommand(IServiceProvider services, StellaOpsCliOptions options, Option<bool> verboseOption, CancellationToken cancellationToken)
|
||||
{
|
||||
_ = options;
|
||||
var tenants = new Command("tenants", "Manage tenant contexts (CLI-TEN-47-001).");
|
||||
|
||||
var list = new Command("list", "List available tenants for the authenticated principal.");
|
||||
var tenantOption = new Option<string?>("--tenant")
|
||||
{
|
||||
Description = "Tenant context to use for the request (required for multi-tenant environments)."
|
||||
};
|
||||
var jsonOption = new Option<bool>("--json")
|
||||
{
|
||||
Description = "Output tenant list in JSON format."
|
||||
};
|
||||
|
||||
list.Add(tenantOption);
|
||||
list.Add(jsonOption);
|
||||
|
||||
list.SetAction((parseResult, _) =>
|
||||
{
|
||||
var tenant = parseResult.GetValue(tenantOption);
|
||||
var json = parseResult.GetValue(jsonOption);
|
||||
var verbose = parseResult.GetValue(verboseOption);
|
||||
return CommandHandlers.HandleTenantsListAsync(services, options, tenant, json, verbose, cancellationToken);
|
||||
});
|
||||
|
||||
var use = new Command("use", "Set the active tenant context for subsequent commands.");
|
||||
var tenantIdArgument = new Argument<string>("tenant-id")
|
||||
{
|
||||
Description = "Tenant identifier to use as the default context."
|
||||
};
|
||||
use.Add(tenantIdArgument);
|
||||
|
||||
use.SetAction((parseResult, _) =>
|
||||
{
|
||||
var tenantId = parseResult.GetValue(tenantIdArgument) ?? string.Empty;
|
||||
var verbose = parseResult.GetValue(verboseOption);
|
||||
return CommandHandlers.HandleTenantsUseAsync(services, options, tenantId, verbose, cancellationToken);
|
||||
});
|
||||
|
||||
var current = new Command("current", "Show the currently active tenant context.");
|
||||
var currentJsonOption = new Option<bool>("--json")
|
||||
{
|
||||
Description = "Output profile in JSON format."
|
||||
};
|
||||
current.Add(currentJsonOption);
|
||||
|
||||
current.SetAction((parseResult, _) =>
|
||||
{
|
||||
var json = parseResult.GetValue(currentJsonOption);
|
||||
var verbose = parseResult.GetValue(verboseOption);
|
||||
return CommandHandlers.HandleTenantsCurrentAsync(json, verbose, cancellationToken);
|
||||
});
|
||||
|
||||
var clear = new Command("clear", "Clear the active tenant context (use default or require --tenant).");
|
||||
|
||||
clear.SetAction((_, _) =>
|
||||
{
|
||||
return CommandHandlers.HandleTenantsClearAsync(cancellationToken);
|
||||
});
|
||||
|
||||
tenants.Add(list);
|
||||
tenants.Add(use);
|
||||
tenants.Add(current);
|
||||
tenants.Add(clear);
|
||||
return tenants;
|
||||
}
|
||||
|
||||
private static Command BuildPolicyCommand(IServiceProvider services, StellaOpsCliOptions options, Option<bool> verboseOption, CancellationToken cancellationToken)
|
||||
{
|
||||
_ = options;
|
||||
|
||||
Reference in New Issue
Block a user