import Foundation /// What `build list` is narrowed to: `--ref`, `--status` and `--job`. /// There is no state flag, so the default sends the bare command. nonisolated struct BuildFilter: Equatable, Sendable { /// The vocabulary `--status` accepts; anything else is a usage error. enum Status: String, CaseIterable, Identifiable, Sendable { case pending, running, success, failure, cancelled var id: String { rawValue } } var ref = "" var status: Status? var job: String? func flags() -> [String] { var flags = filterFlag("--ref", ref) flags += filterFlag("--status", status?.rawValue) flags += filterFlag("--job", job) return flags } var isNarrowed: Bool { !flags().isEmpty } var emptyMessage: String { isNarrowed ? "No builds match these filters." : "No builds. Builds run when a push touches a repo with a .gitbay/ job file." } }