From 23aedead7ffed9645f30c494b918e08dd4d1c057 Mon Sep 17 00:00:00 2001 From: Kyle Newsome Date: Wed, 14 Nov 2018 22:11:43 -0500 Subject: [PATCH] Shell fix and some other quick prettiness for output --- Sources/Slurp/BasicTask.swift | 9 +++++++++ Sources/Slurp/Rx+Extensions.swift | 1 + Sources/Slurp/Shell.swift | 6 ++++-- Sources/Slurp/Slurp.swift | 1 + Sources/SlurpXCTools/ApplicationLoader.swift | 7 +++++++ 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Sources/Slurp/BasicTask.swift b/Sources/Slurp/BasicTask.swift index 91f90bc..58850dd 100644 --- a/Sources/Slurp/BasicTask.swift +++ b/Sources/Slurp/BasicTask.swift @@ -15,9 +15,18 @@ public protocol SlurpTask { associatedtype OutputType + var name: String { get } + func onPipe(from input: U) -> Observable } +extension SlurpTask { + + public var name: String { + return String(describing: self) + } +} + public class RegisteredTask { let name: String diff --git a/Sources/Slurp/Rx+Extensions.swift b/Sources/Slurp/Rx+Extensions.swift index 2e1967e..9b82c5d 100644 --- a/Sources/Slurp/Rx+Extensions.swift +++ b/Sources/Slurp/Rx+Extensions.swift @@ -33,6 +33,7 @@ extension ObservableType { public func pipe(to: S) -> Observable { return flatMap({ (element) -> Observable in + print("\n----- Running \(to.name) \n") return to.onPipe(from: element) }) } diff --git a/Sources/Slurp/Shell.swift b/Sources/Slurp/Shell.swift index 426b3d8..3e27f3f 100644 --- a/Sources/Slurp/Shell.swift +++ b/Sources/Slurp/Shell.swift @@ -59,10 +59,12 @@ open class Shell: SlurpTask { public static func createObservable(arguments: [String]) -> Observable<(Int32, String?)> { return Observable<(Int32, String?)>.create({ (observer) -> Disposable in - print("$", arguments.joined(separator: " ")) + let command = arguments.joined(separator: " ") + print("$", command) + let process = Slurp.processType.init() process.launchPath = "/bin/bash" - process.arguments = ["-c"] + arguments + process.arguments = ["-c", command] if let cwd = Slurp.currentWorkingDirectory { process.currentWorkingDirectory = Path(cwd).absolute().string diff --git a/Sources/Slurp/Slurp.swift b/Sources/Slurp/Slurp.swift index 9393912..33ff65d 100644 --- a/Sources/Slurp/Slurp.swift +++ b/Sources/Slurp/Slurp.swift @@ -51,6 +51,7 @@ public class Slurp { } public func startWith(_ task: S) -> Observable { + print("\n----- Running \(task.name) \n") return task.onPipe(from: ()) } diff --git a/Sources/SlurpXCTools/ApplicationLoader.swift b/Sources/SlurpXCTools/ApplicationLoader.swift index 1f3678f..dd55e3f 100644 --- a/Sources/SlurpXCTools/ApplicationLoader.swift +++ b/Sources/SlurpXCTools/ApplicationLoader.swift @@ -55,6 +55,13 @@ public class ApplicationLoader: Shell { } super.init(arguments: arguments) + + let shellObs = self.observable + self.observable = Observable.just(()) + .flatMap({ () -> Observable<(Int32, String?)> in + print("\n--- Uploading App, this may take several minutes\n") + return shellObs + }) } }