| 1 | | /// What `covane history` was asked to do, read from the arguments after the command word. |
| 2 | | public struct HistoryOptions: Sendable, Equatable { |
| 3 | | public static let commandWord = "history" |
| 4 | | |
| 5 | | public static let usage = """ |
| 6 | | usage: covane history --runs <folder of <commit>/totals.json> --output <page.html> |
| 7 | | [--title <text>] |
| 8 | | """ |
| 9 | | |
| 10 | | /// The folder whose subfolders are one run each (DESIGN.md D7). |
| 11 | | public let runsFolder: String |
| 12 | | /// The page to write; `report.css` goes beside it. |
| 13 | | public let outputPath: String |
| 14 | | public let title: String |
| 15 | | |
| 16 | | /// - Throws: `ReportOptionsError` for an unknown option, an option without its value |
| 17 | | /// or a missing required option. |
| 18 | 5 | public init(arguments: [String]) throws { |
| 19 | 5 | let values = try OptionValues(arguments: arguments, allowed: Self.options) |
| 20 | 3 | runsFolder = try values.required("--runs") |
| 21 | 3 | outputPath = try values.required("--output") |
| 22 | 2 | title = values["--title"] ?? ReportOptions.defaultTitle |
| 23 | 2 | } |
| 24 | | |
| 25 | | private static let options: Set = ["--runs", "--output", "--title"] |
| 26 | | } |