1/// What `covane unavailable` was asked to do, read from the arguments after the command
2/// word.
3public 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.
247 public init(arguments: [String]) throws {
257 let values = try OptionValues(arguments: arguments, allowed: Self.options)
265 outputFolder = try values.required("--output")
274 reason = try values.required("--reason")
283 title = values["--title"] ?? ReportOptions.defaultTitle
293 commit = values["--commit"]
303 subject = values["--subject"]
313 runURL = try values.runURL()
323 junitInputs = try values.all("--junit").map(JUnitInput.init)
333 }
34
35 private static let options: Set = [
36 "--output", "--reason", "--title", "--commit", "--subject", "--run-url", "--junit",
37 ]
38}