Skip to content

Commit f0602de

Browse files
committed
Minor fixes
1 parent 29e7e41 commit f0602de

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

Sources/Commands/Error.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func print(error: Any) {
5454

5555
func print(diagnostic: Diagnostic, stdoutStream: OutputByteStream) {
5656

57-
let writer = InteractiveWriter.stderr
57+
let writer = InteractiveWriter(stream: stdoutStream)
5858

5959
if !(diagnostic.location is UnknownLocation) {
6060
writer.write(diagnostic.location.description)
@@ -78,6 +78,12 @@ func print(diagnostic: Diagnostic, stdoutStream: OutputByteStream) {
7878
writer.write("\n")
7979
}
8080

81+
extension Diagnostic: ByteStreamable {
82+
public func write(to stream: WritableByteStream) {
83+
print(diagnostic: self, stdoutStream: stream)
84+
}
85+
}
86+
8187
/// This class is used to write on the underlying stream.
8288
///
8389
/// If underlying stream is a not tty, the string will be written in without any

Sources/Commands/SwiftScriptTool.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ extension SwiftScriptTool {
9191
@OptionGroup()
9292
var options: ScriptToolOptions
9393

94-
/// Whether to print build progress.
95-
@Flag(help: "Print build progress")
94+
/// Whether to show build output.
95+
@Flag(help: "Print build output")
9696
var quiet: Bool = false
9797

9898
func run(_ swiftTool: SwiftTool, as productName: String, at cacheDirPath: AbsolutePath) throws {
@@ -102,9 +102,7 @@ extension SwiftScriptTool {
102102
} else {
103103
swiftTool.redirectStdoutToStderr()
104104
}
105-
// FIXME: More elegant solution?
106-
print(diagnostic: .init(message: .note("Using cache: \(cacheDirPath.basename)")),
107-
stdoutStream: swiftTool.stdoutStream)
105+
swiftTool.stdoutStream <<< Diagnostic(message: .note("Using cache: \(cacheDirPath.basename)"))
108106

109107
do {
110108
let buildSystem = try swiftTool.createBuildSystem(explicitProduct: nil)

Sources/ScriptParse/ScriptParse.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ extension ScriptParse {
9393
public func run() throws {
9494
let path = try AbsolutePath(validating: file)
9595
let json = try ScriptParse.manifest(for: path)
96-
print(String(data: json, encoding: .utf8)!)
96+
print(String(decoding: json, as: UTF8.self))
9797
}
9898

9999
// FIXME: This should be removed some day.

0 commit comments

Comments
 (0)