@@ -10,6 +10,7 @@ import XcbeautifyLib
10
10
11
11
public protocol ShellService {
12
12
func execute( arguments: [ String ] ) throws
13
+ func executeWithVisibleOutput( arguments: [ String ] ) throws
13
14
func executeWithResult( arguments: [ String ] ) throws -> String
14
15
func executeWithXCBeautify( arguments: [ String ] ) throws
15
16
}
@@ -24,17 +25,21 @@ final class ShellServiceImpl: ShellService {
24
25
}
25
26
26
27
func execute( arguments: [ String ] ) throws {
27
- try executeTask ( arguments: arguments)
28
+ try executeTask ( arguments: arguments, isOutputVisible: verboseController. isVerbose ( ) )
29
+ }
30
+
31
+ func executeWithVisibleOutput( arguments: [ String ] ) throws {
32
+ try executeTask ( arguments: arguments, isOutputVisible: true )
28
33
}
29
34
30
35
func executeWithResult( arguments: [ String ] ) throws -> String {
31
- return try executeTask ( arguments: arguments)
36
+ return try executeTask ( arguments: arguments, isOutputVisible : verboseController . isVerbose ( ) )
32
37
}
33
38
34
- @discardableResult private func executeTask( arguments: [ String ] ) throws -> String {
39
+ @discardableResult private func executeTask( arguments: [ String ] , isOutputVisible : Bool ) throws -> String {
35
40
let output = CaptureStream ( )
36
41
let error = CaptureStream ( )
37
- let outputStream = makeOutputStream ( captureStream: output)
42
+ let outputStream = makeOutputStream ( captureStream: output, isOutputVisible : isOutputVisible )
38
43
39
44
let command = arguments. joined ( separator: " " )
40
45
let task = Task ( executable: " /bin/bash " , arguments: [ " -c " , command] , stdout: outputStream, stderr: error)
@@ -53,8 +58,8 @@ final class ShellServiceImpl: ShellService {
53
58
return outputString
54
59
}
55
60
56
- private func makeOutputStream( captureStream: CaptureStream ) -> WritableStream {
57
- if verboseController . isVerbose ( ) {
61
+ private func makeOutputStream( captureStream: CaptureStream , isOutputVisible : Bool ) -> WritableStream {
62
+ if isOutputVisible {
58
63
return SplitStream ( streams: [ captureStream, WriteStream . stdout] )
59
64
} else {
60
65
return captureStream
0 commit comments