| 1 | | /// What `covane unavailable` was asked to do, read from the arguments after the command |
| 2 | | /// word. |
| 3 | | public struct UnavailableOptions: Sendable, Equatable { |
| 4 | | public static let commandWord = "unavailable" |
| 5 | | |
| 6 | | public static let usage = """ |
| 7 | | usage: covane unavailable --output <site folder> --reason <text> |
| 8 | | [--title <text>] [--commit <sha>] [--subject <text>] |
| 9 | | """ |
| 10 | | |
| 11 | | /// The folder to write the run's files to, as `--output` of a normal run. |
| 12 | | public let outputFolder: String |
| 13 | | /// Why the run has no coverage, such as "Package tests failed". Untrusted text. |
| 14 | | public let reason: String |
| 15 | | public let title: String |
| 16 | | public let commit: String? |
| 17 | | public let subject: String? |
| 18 | | |
| 19 | | /// - Throws: `ReportOptionsError` for an unknown option, an option without its value |
| 20 | | /// or a missing required option. |
| 21 | 6 | public init(arguments: [String]) throws { |
| 22 | 6 | let values = try OptionValues(arguments: arguments, allowed: Self.options) |
| 23 | 4 | outputFolder = try values.required("--output") |
| 24 | 3 | reason = try values.required("--reason") |
| 25 | 2 | title = values["--title"] ?? ReportOptions.defaultTitle |
| 26 | 2 | commit = values["--commit"] |
| 27 | 2 | subject = values["--subject"] |
| 28 | 2 | } |
| 29 | | |
| 30 | | private static let options: Set = ["--output", "--reason", "--title", "--commit", "--subject"] |
| 31 | | } |