Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
stevapple committed Aug 12, 2021
1 parent 29e7e41 commit f0602de
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
8 changes: 7 additions & 1 deletion Sources/Commands/Error.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func print(error: Any) {

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

let writer = InteractiveWriter.stderr
let writer = InteractiveWriter(stream: stdoutStream)

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

extension Diagnostic: ByteStreamable {
public func write(to stream: WritableByteStream) {
print(diagnostic: self, stdoutStream: stream)
}
}

/// This class is used to write on the underlying stream.
///
/// If underlying stream is a not tty, the string will be written in without any
Expand Down
8 changes: 3 additions & 5 deletions Sources/Commands/SwiftScriptTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ extension SwiftScriptTool {
@OptionGroup()
var options: ScriptToolOptions

/// Whether to print build progress.
@Flag(help: "Print build progress")
/// Whether to show build output.
@Flag(help: "Print build output")
var quiet: Bool = false

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

do {
let buildSystem = try swiftTool.createBuildSystem(explicitProduct: nil)
Expand Down
2 changes: 1 addition & 1 deletion Sources/ScriptParse/ScriptParse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ extension ScriptParse {
public func run() throws {
let path = try AbsolutePath(validating: file)
let json = try ScriptParse.manifest(for: path)
print(String(data: json, encoding: .utf8)!)
print(String(decoding: json, as: UTF8.self))
}

// FIXME: This should be removed some day.
Expand Down

0 comments on commit f0602de

Please sign in to comment.