Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions Sources/ContainerCommands/BuildCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ extension Application {
return config
}

enum ProgressType: String, ExpressibleByArgument {
case auto
case plain
case tty
}

@Option(
name: .shortAndLong,
help: ArgumentHelp("Add the architecture type to the build", valueName: "value"),
Expand Down Expand Up @@ -99,8 +105,8 @@ extension Application {
)
var platform: [[String]] = [[]]

@Option(name: .long, help: ArgumentHelp("Progress type (format: auto|plain|tty)]", valueName: "type"))
var progress: String = "auto"
@Option(name: .long, help: ArgumentHelp("Progress type (format: auto|plain|tty)", valueName: "type"))
var progress: ProgressType = .auto

@Flag(name: .shortAndLong, help: "Suppress build output")
var quiet: Bool = false
Expand Down Expand Up @@ -221,14 +227,12 @@ extension Application {

var terminal: Terminal?
switch self.progress {
case "tty":
case .tty:
terminal = try Terminal(descriptor: STDERR_FILENO)
case "auto":
case .auto:
terminal = try? Terminal(descriptor: STDERR_FILENO)
case "plain":
case .plain:
terminal = nil
default:
throw ContainerizationError(.invalidArgument, message: "invalid progress mode \(self.progress)")
}

defer { terminal?.tryReset() }
Expand Down