|
5 | 5 | // Configuration keys for reading from providers |
6 | 6 | // |
7 | 7 |
|
| 8 | +import ConfigKeyKit |
8 | 9 | import Foundation |
9 | 10 |
|
10 | 11 | /// Configuration keys for reading from providers |
11 | 12 | internal enum ConfigurationKeys { |
| 13 | + // MARK: - CloudKit Configuration |
| 14 | + |
12 | 15 | /// CloudKit configuration keys |
13 | 16 | internal enum CloudKit { |
14 | | - internal static let containerID = "cloudkit.container_id" |
15 | | - internal static let containerIDEnv = "CLOUDKIT_CONTAINER_ID" |
16 | | - internal static let keyID = "cloudkit.key_id" |
17 | | - internal static let keyIDEnv = "CLOUDKIT_KEY_ID" |
18 | | - internal static let privateKeyPath = "cloudkit.private_key_path" |
19 | | - internal static let privateKeyPathEnv = "CLOUDKIT_PRIVATE_KEY_PATH" |
| 17 | + // Using base key with auto-generation (no prefix for CloudKit ENV vars) |
| 18 | + internal static let containerID = ConfigKey<String>( |
| 19 | + "cloudkit.container_id", |
| 20 | + envPrefix: nil, // Generates: CLI="cloudkit.container_id", ENV="CLOUDKIT_CONTAINER_ID" |
| 21 | + default: "iCloud.com.brightdigit.Bushel" |
| 22 | + ) |
| 23 | + |
| 24 | + internal static let keyID = OptionalConfigKey<String>( |
| 25 | + "cloudkit.key_id", |
| 26 | + envPrefix: nil |
| 27 | + ) |
| 28 | + |
| 29 | + internal static let privateKeyPath = OptionalConfigKey<String>( |
| 30 | + "cloudkit.private_key_path", |
| 31 | + envPrefix: nil |
| 32 | + ) |
20 | 33 | } |
21 | 34 |
|
| 35 | + // MARK: - VirtualBuddy Configuration |
| 36 | + |
22 | 37 | /// VirtualBuddy TSS API configuration keys |
23 | 38 | internal enum VirtualBuddy { |
24 | | - internal static let apiKey = "virtualbuddy.api_key" |
25 | | - internal static let apiKeyEnv = "VIRTUALBUDDY_API_KEY" |
| 39 | + internal static let apiKey = OptionalConfigKey<String>( |
| 40 | + "virtualbuddy.api_key", |
| 41 | + envPrefix: nil // Generates: ENV="VIRTUALBUDDY_API_KEY" |
| 42 | + ) |
26 | 43 | } |
27 | 44 |
|
| 45 | + // MARK: - Fetch Configuration |
| 46 | + |
28 | 47 | /// Fetch throttling configuration keys |
29 | 48 | internal enum Fetch { |
30 | | - internal static let intervalGlobal = "fetch.interval_global" |
31 | | - internal static let intervalGlobalEnv = "BUSHEL_FETCH_INTERVAL_GLOBAL" |
| 49 | + internal static let intervalGlobal = OptionalConfigKey<Double>( |
| 50 | + bushelPrefixed: "fetch.interval_global" // Generates: ENV="BUSHEL_FETCH_INTERVAL_GLOBAL" |
| 51 | + ) |
32 | 52 |
|
33 | | - /// Per-source interval key prefix (e.g., "fetch.interval.appledb_dev") |
34 | | - internal static func intervalKey(for source: String) -> String { |
35 | | - "fetch.interval.\(source.replacingOccurrences(of: ".", with: "_"))" |
| 53 | + /// Generate per-source interval key dynamically |
| 54 | + /// - Parameter source: Data source identifier (e.g., "appledb.dev") |
| 55 | + /// - Returns: An OptionalConfigKey<Double> for the source-specific interval |
| 56 | + internal static func intervalKey(for source: String) -> OptionalConfigKey<Double> { |
| 57 | + let normalized = source.replacingOccurrences(of: ".", with: "_") |
| 58 | + return OptionalConfigKey<Double>( |
| 59 | + "fetch.interval.\(normalized)", |
| 60 | + envPrefix: nil // CLI: "fetch.interval.appledb_dev", ENV: "FETCH_INTERVAL_APPLEDB_DEV" |
| 61 | + ) |
36 | 62 | } |
37 | 63 | } |
38 | 64 |
|
39 | | - /// Sync command configuration keys |
| 65 | + // MARK: - Sync Command Configuration |
| 66 | + |
| 67 | + /// Sync command configuration keys (using base key with BUSHEL prefix) |
40 | 68 | internal enum Sync { |
41 | | - internal static let dryRun = "sync.dry_run" |
42 | | - internal static let restoreImagesOnly = "sync.restore_images_only" |
43 | | - internal static let xcodeOnly = "sync.xcode_only" |
44 | | - internal static let swiftOnly = "sync.swift_only" |
45 | | - internal static let noBetas = "sync.no_betas" |
46 | | - internal static let noAppleWiki = "sync.no_apple_wiki" |
47 | | - internal static let verbose = "sync.verbose" |
48 | | - internal static let force = "sync.force" |
49 | | - internal static let minInterval = "sync.min_interval" |
50 | | - internal static let source = "sync.source" |
| 69 | + internal static let dryRun = ConfigKey<Bool>(bushelPrefixed: "sync.dry_run") |
| 70 | + internal static let restoreImagesOnly = ConfigKey<Bool>(bushelPrefixed: "sync.restore_images_only") |
| 71 | + internal static let xcodeOnly = ConfigKey<Bool>(bushelPrefixed: "sync.xcode_only") |
| 72 | + internal static let swiftOnly = ConfigKey<Bool>(bushelPrefixed: "sync.swift_only") |
| 73 | + internal static let noBetas = ConfigKey<Bool>(bushelPrefixed: "sync.no_betas") |
| 74 | + internal static let noAppleWiki = ConfigKey<Bool>(bushelPrefixed: "sync.no_apple_wiki") |
| 75 | + internal static let verbose = ConfigKey<Bool>(bushelPrefixed: "sync.verbose") |
| 76 | + internal static let force = ConfigKey<Bool>(bushelPrefixed: "sync.force") |
| 77 | + internal static let minInterval = OptionalConfigKey<Int>(bushelPrefixed: "sync.min_interval") |
| 78 | + internal static let source = OptionalConfigKey<String>(bushelPrefixed: "sync.source") |
51 | 79 | } |
52 | 80 |
|
| 81 | + // MARK: - Export Command Configuration |
| 82 | + |
53 | 83 | /// Export command configuration keys |
54 | 84 | internal enum Export { |
55 | | - internal static let output = "export.output" |
56 | | - internal static let pretty = "export.pretty" |
57 | | - internal static let signedOnly = "export.signed_only" |
58 | | - internal static let noBetas = "export.no_betas" |
59 | | - internal static let verbose = "export.verbose" |
| 85 | + internal static let output = OptionalConfigKey<String>(bushelPrefixed: "export.output") |
| 86 | + internal static let pretty = ConfigKey<Bool>(bushelPrefixed: "export.pretty") |
| 87 | + internal static let signedOnly = ConfigKey<Bool>(bushelPrefixed: "export.signed_only") |
| 88 | + internal static let noBetas = ConfigKey<Bool>(bushelPrefixed: "export.no_betas") |
| 89 | + internal static let verbose = ConfigKey<Bool>(bushelPrefixed: "export.verbose") |
60 | 90 | } |
61 | 91 |
|
| 92 | + // MARK: - Status Command Configuration |
| 93 | + |
62 | 94 | /// Status command configuration keys |
63 | 95 | internal enum Status { |
64 | | - internal static let errorsOnly = "status.errors_only" |
65 | | - internal static let detailed = "status.detailed" |
| 96 | + internal static let errorsOnly = ConfigKey<Bool>(bushelPrefixed: "status.errors_only") |
| 97 | + internal static let detailed = ConfigKey<Bool>(bushelPrefixed: "status.detailed") |
66 | 98 | } |
67 | 99 |
|
| 100 | + // MARK: - List Command Configuration |
| 101 | + |
68 | 102 | /// List command configuration keys |
69 | 103 | internal enum List { |
70 | | - internal static let restoreImages = "list.restore_images" |
71 | | - internal static let xcodeVersions = "list.xcode_versions" |
72 | | - internal static let swiftVersions = "list.swift_versions" |
| 104 | + internal static let restoreImages = ConfigKey<Bool>(bushelPrefixed: "list.restore_images") |
| 105 | + internal static let xcodeVersions = ConfigKey<Bool>(bushelPrefixed: "list.xcode_versions") |
| 106 | + internal static let swiftVersions = ConfigKey<Bool>(bushelPrefixed: "list.swift_versions") |
73 | 107 | } |
74 | 108 |
|
| 109 | + // MARK: - Clear Command Configuration |
| 110 | + |
75 | 111 | /// Clear command configuration keys |
76 | 112 | internal enum Clear { |
77 | | - internal static let yes = "clear.yes" |
78 | | - internal static let verbose = "clear.verbose" |
| 113 | + internal static let yes = ConfigKey<Bool>(bushelPrefixed: "clear.yes") |
| 114 | + internal static let verbose = ConfigKey<Bool>(bushelPrefixed: "clear.verbose") |
79 | 115 | } |
80 | 116 | } |
0 commit comments