Skip to content

Commit

Permalink
add option hide-build
Browse files Browse the repository at this point in the history
  • Loading branch information
k-kohey committed Jan 11, 2023
1 parent 5199e43 commit a50373f
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion Sources/Commands/SwiftRunTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ struct RunToolOptions: ParsableArguments {
@Flag(name: .customLong("build-tests"), help: "Build both source and test targets")
var shouldBuildTests: Bool = false

/// If the build log should be hidden.
@Flag(name: .customLong("hide-build"), help: "Hides the build log and displays only the runtime log")
var shouldHideBuildLog: Bool = false

/// The executable product to run.
@Argument(help: "The executable to run", completion: .shellCommand("swift package completion-tool list-executables"))
var executable: String?
Expand Down Expand Up @@ -191,7 +195,10 @@ public struct SwiftRunTool: SwiftCommand {
}

do {
let buildSystem = try swiftTool.createBuildSystem(explicitProduct: options.executable)
let buildSystem = try swiftTool.createBuildSystem(
explicitProduct: options.executable,
customOutputStream: options.shouldHideBuildLog ? NullStream() : .none
)
let productName = try findProductName(in: buildSystem.getPackageGraph())
if options.shouldBuildTests {
try buildSystem.build(subset: .allIncludingTests)
Expand Down Expand Up @@ -301,3 +308,17 @@ private extension Basics.Diagnostic {
}
}

private final class NullStream: WritableByteStream {
var position: Int = 0

func write(_ byte: UInt8) {

}

func write<C>(_ bytes: C) where C : Collection, C.Element == UInt8 {

}

func flush() {}
}

0 comments on commit a50373f

Please sign in to comment.