| | | 1 | | using System.Globalization; |
| | | 2 | | using System.ComponentModel; |
| | | 3 | | using EHonda.KicktippAi.Core; |
| | | 4 | | using Spectre.Console; |
| | | 5 | | using Spectre.Console.Cli; |
| | | 6 | | |
| | | 7 | | namespace Orchestrator.Commands.Operations.Wm26RecentHistory; |
| | | 8 | | |
| | | 9 | | public class Wm26RecentHistorySettings : CommandSettings |
| | | 10 | | { |
| | | 11 | | } |
| | | 12 | | |
| | | 13 | | public sealed class Wm26RecentHistoryExportDateMapSettings : Wm26RecentHistorySettings |
| | | 14 | | { |
| | | 15 | | [CommandOption("-c|--community-context <COMMUNITY_CONTEXT>")] |
| | | 16 | | [Description("The community context whose latest WM26 recent-history documents should be exported")] |
| | | 17 | | public string CommunityContext { get; set; } = string.Empty; |
| | | 18 | | |
| | | 19 | | [CommandOption("--competition <COMPETITION>")] |
| | | 20 | | [Description("Competition identifier")] |
| | | 21 | | public string Competition { get; set; } = CompetitionIds.FifaWorldCup2026; |
| | | 22 | | |
| | | 23 | | [CommandOption("-o|--output <OUTPUT>")] |
| | | 24 | | [Description("Canonical date map CSV path")] |
| | | 25 | | public string Output { get; set; } = "data/wm26/recent-history/recent-history-match-dates.csv"; |
| | | 26 | | |
| | | 27 | | [CommandOption("--verbose")] |
| | | 28 | | [Description("Enable verbose output")] |
| | | 29 | | public bool Verbose { get; set; } |
| | | 30 | | |
| | | 31 | | public override ValidationResult Validate() |
| | | 32 | | { |
| | | 33 | | return string.IsNullOrWhiteSpace(CommunityContext) |
| | | 34 | | ? ValidationResult.Error("--community-context is required") |
| | | 35 | | : ValidationResult.Success(); |
| | | 36 | | } |
| | | 37 | | } |
| | | 38 | | |
| | | 39 | | public sealed class Wm26RecentHistoryApplyDateMapSettings : Wm26RecentHistorySettings |
| | | 40 | | { |
| | | 41 | | [CommandOption("-c|--community-context <COMMUNITY_CONTEXT>")] |
| | | 42 | | [Description("The community context whose latest WM26 recent-history documents should be updated")] |
| | 1 | 43 | | public string CommunityContext { get; set; } = string.Empty; |
| | | 44 | | |
| | | 45 | | [CommandOption("--competition <COMPETITION>")] |
| | | 46 | | [Description("Competition identifier")] |
| | 1 | 47 | | public string Competition { get; set; } = CompetitionIds.FifaWorldCup2026; |
| | | 48 | | |
| | | 49 | | [CommandOption("-i|--input <INPUT>")] |
| | | 50 | | [Description("Canonical date map CSV path")] |
| | 1 | 51 | | public string Input { get; set; } = "data/wm26/recent-history/recent-history-match-dates.csv"; |
| | | 52 | | |
| | | 53 | | [CommandOption("--dry-run")] |
| | | 54 | | [Description("Show what would be saved without writing Firestore documents")] |
| | | 55 | | public bool DryRun { get; set; } |
| | | 56 | | |
| | | 57 | | [CommandOption("--apply-known-only")] |
| | | 58 | | [Description("Apply exact dates for known map rows while preserving unmapped rows")] |
| | | 59 | | public bool ApplyKnownOnly { get; set; } |
| | | 60 | | |
| | | 61 | | [CommandOption("--preserve-collected-on-or-after <DATE>")] |
| | | 62 | | [Description("When applying known rows only, resolve WM tournament rows whose Played_At or legacy Data_Collected_At |
| | | 63 | | public string? PreserveCollectedOnOrAfter { get; set; } |
| | | 64 | | |
| | | 65 | | [CommandOption("--verbose")] |
| | | 66 | | [Description("Enable verbose output")] |
| | | 67 | | public bool Verbose { get; set; } |
| | | 68 | | |
| | | 69 | | public override ValidationResult Validate() |
| | | 70 | | { |
| | 1 | 71 | | if (string.IsNullOrWhiteSpace(CommunityContext)) |
| | | 72 | | { |
| | 0 | 73 | | return ValidationResult.Error("--community-context is required"); |
| | | 74 | | } |
| | | 75 | | |
| | 1 | 76 | | if (!string.IsNullOrWhiteSpace(PreserveCollectedOnOrAfter)) |
| | | 77 | | { |
| | 1 | 78 | | if (!ApplyKnownOnly) |
| | | 79 | | { |
| | 0 | 80 | | return ValidationResult.Error("--preserve-collected-on-or-after requires --apply-known-only"); |
| | | 81 | | } |
| | | 82 | | |
| | 1 | 83 | | if (!DateOnly.TryParseExact( |
| | 1 | 84 | | PreserveCollectedOnOrAfter.Trim(), |
| | 1 | 85 | | "yyyy-MM-dd", |
| | 1 | 86 | | CultureInfo.InvariantCulture, |
| | 1 | 87 | | DateTimeStyles.None, |
| | 1 | 88 | | out _)) |
| | | 89 | | { |
| | 0 | 90 | | return ValidationResult.Error("--preserve-collected-on-or-after must use YYYY-MM-DD"); |
| | | 91 | | } |
| | | 92 | | } |
| | | 93 | | |
| | 1 | 94 | | return ValidationResult.Success(); |
| | | 95 | | } |
| | | 96 | | } |
| | | 97 | | |
| | | 98 | | public sealed class Wm26RecentHistoryProbePredictionLookupSettings : Wm26RecentHistorySettings |
| | | 99 | | { |
| | | 100 | | [CommandOption("-c|--community-context <COMMUNITY_CONTEXT>")] |
| | | 101 | | [Description("The community context whose match predictions should be queried")] |
| | | 102 | | public string CommunityContext { get; set; } = string.Empty; |
| | | 103 | | |
| | | 104 | | [CommandOption("--competition <COMPETITION>")] |
| | | 105 | | [Description("Competition identifier")] |
| | | 106 | | public string Competition { get; set; } = CompetitionIds.FifaWorldCup2026; |
| | | 107 | | |
| | | 108 | | [CommandOption("--home-team <HOME_TEAM>")] |
| | | 109 | | [Description("Home team name to query exactly")] |
| | | 110 | | public string HomeTeam { get; set; } = string.Empty; |
| | | 111 | | |
| | | 112 | | [CommandOption("--away-team <AWAY_TEAM>")] |
| | | 113 | | [Description("Away team name to query exactly")] |
| | | 114 | | public string AwayTeam { get; set; } = string.Empty; |
| | | 115 | | |
| | | 116 | | [CommandOption("--verbose")] |
| | | 117 | | [Description("Enable verbose output")] |
| | | 118 | | public bool Verbose { get; set; } |
| | | 119 | | |
| | | 120 | | public override ValidationResult Validate() |
| | | 121 | | { |
| | | 122 | | if (string.IsNullOrWhiteSpace(CommunityContext)) |
| | | 123 | | { |
| | | 124 | | return ValidationResult.Error("--community-context is required"); |
| | | 125 | | } |
| | | 126 | | |
| | | 127 | | if (string.IsNullOrWhiteSpace(HomeTeam)) |
| | | 128 | | { |
| | | 129 | | return ValidationResult.Error("--home-team is required"); |
| | | 130 | | } |
| | | 131 | | |
| | | 132 | | if (string.IsNullOrWhiteSpace(AwayTeam)) |
| | | 133 | | { |
| | | 134 | | return ValidationResult.Error("--away-team is required"); |
| | | 135 | | } |
| | | 136 | | |
| | | 137 | | return ValidationResult.Success(); |
| | | 138 | | } |
| | | 139 | | } |