| | | 1 | | using System.ComponentModel; |
| | | 2 | | using Spectre.Console; |
| | | 3 | | using Spectre.Console.Cli; |
| | | 4 | | |
| | | 5 | | namespace Orchestrator.Commands.Utility.CopyFirestoreContext; |
| | | 6 | | |
| | | 7 | | public sealed class CopyFirestoreContextSettings : CommandSettings |
| | | 8 | | { |
| | | 9 | | [CommandOption("--source-community-context <COMMUNITY_CONTEXT>")] |
| | | 10 | | [Description("Community context to copy documents from")] |
| | 1 | 11 | | public string SourceCommunityContext { get; set; } = string.Empty; |
| | | 12 | | |
| | | 13 | | [CommandOption("--target-community-context <COMMUNITY_CONTEXT>")] |
| | | 14 | | [Description("Community context to copy documents to")] |
| | 1 | 15 | | public string TargetCommunityContext { get; set; } = string.Empty; |
| | | 16 | | |
| | | 17 | | [CommandOption("--competition <COMPETITION>")] |
| | | 18 | | [Description("Competition identifier")] |
| | | 19 | | public string? Competition { get; set; } |
| | | 20 | | |
| | | 21 | | [CommandOption("--context-prefix <PREFIX>")] |
| | | 22 | | [Description("Comma-separated context document prefixes to copy")] |
| | | 23 | | public string? ContextPrefix { get; set; } |
| | | 24 | | |
| | | 25 | | [CommandOption("--kpi-document <DOCUMENT_NAME>")] |
| | | 26 | | [Description("Comma-separated KPI document names to copy")] |
| | | 27 | | public string? KpiDocument { get; set; } |
| | | 28 | | |
| | | 29 | | [CommandOption("--dry-run")] |
| | | 30 | | [Description("Validate and show the copy plan without writing Firestore documents")] |
| | | 31 | | [DefaultValue(false)] |
| | | 32 | | public bool DryRun { get; set; } |
| | | 33 | | |
| | | 34 | | [CommandOption("-v|--verbose")] |
| | | 35 | | [Description("Enable verbose output")] |
| | | 36 | | [DefaultValue(false)] |
| | | 37 | | public bool Verbose { get; set; } |
| | | 38 | | |
| | | 39 | | public override ValidationResult Validate() |
| | | 40 | | { |
| | 1 | 41 | | if (string.IsNullOrWhiteSpace(SourceCommunityContext)) |
| | | 42 | | { |
| | 0 | 43 | | return ValidationResult.Error("--source-community-context is required"); |
| | | 44 | | } |
| | | 45 | | |
| | 1 | 46 | | if (string.IsNullOrWhiteSpace(TargetCommunityContext)) |
| | | 47 | | { |
| | 0 | 48 | | return ValidationResult.Error("--target-community-context is required"); |
| | | 49 | | } |
| | | 50 | | |
| | 1 | 51 | | if (string.Equals(SourceCommunityContext, TargetCommunityContext, StringComparison.OrdinalIgnoreCase)) |
| | | 52 | | { |
| | 0 | 53 | | return ValidationResult.Error("source and target community contexts must differ"); |
| | | 54 | | } |
| | | 55 | | |
| | 1 | 56 | | if (string.IsNullOrWhiteSpace(ContextPrefix) && string.IsNullOrWhiteSpace(KpiDocument)) |
| | | 57 | | { |
| | 0 | 58 | | return ValidationResult.Error("at least one of --context-prefix or --kpi-document is required"); |
| | | 59 | | } |
| | | 60 | | |
| | 1 | 61 | | return ValidationResult.Success(); |
| | | 62 | | } |
| | | 63 | | } |