| 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 | | [--run-url <https-url>] [--junit <[label=]file|folder>]... |
| 10 | | """ |
| 11 | | |
| 12 | | /// The folder to write the run's files to, as `--output` of a normal run. |
| 13 | | public let outputFolder: String |
| 14 | | /// Why the run has no coverage, such as "Package tests failed". Untrusted text. |
| 15 | | public let reason: String |
| 16 | | public let title: String |
| 17 | | public let commit: String? |
| 18 | | public let runURL: String? |
| 19 | | public let junitInputs: [JUnitInput] |
| 20 | | public let subject: String? |
| 21 | | |
| 22 | | /// - Throws: `ReportOptionsError` for an unknown option, an option without its value |
| 23 | | /// or a missing required option. |
| 24 | 7 | public init(arguments: [String]) throws { |
| 25 | 7 | let values = try OptionValues(arguments: arguments, allowed: Self.options) |
| 26 | 5 | outputFolder = try values.required("--output") |
| 27 | 4 | reason = try values.required("--reason") |
| 28 | 3 | title = values["--title"] ?? ReportOptions.defaultTitle |
| 29 | 3 | commit = values["--commit"] |
| 30 | 3 | subject = values["--subject"] |
| 31 | 3 | runURL = try values.runURL() |
| 32 | 3 | junitInputs = try values.all("--junit").map(JUnitInput.init) |
| 33 | 3 | } |
| 34 | | |
| 35 | | private static let options: Set = [ |
| 36 | | "--output", "--reason", "--title", "--commit", "--subject", "--run-url", "--junit", |
| 37 | | ] |
| 38 | | } |