Skip to content

Commit

Permalink
Shell fix and some other quick prettiness for output
Browse files Browse the repository at this point in the history
  • Loading branch information
bitwit committed Nov 15, 2018
1 parent ff7a7d0 commit 23aedea
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 2 deletions.
9 changes: 9 additions & 0 deletions Sources/Slurp/BasicTask.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,18 @@ public protocol SlurpTask {

associatedtype OutputType

var name: String { get }

func onPipe<U>(from input: U) -> Observable<OutputType>
}

extension SlurpTask {

public var name: String {
return String(describing: self)
}
}

public class RegisteredTask {

let name: String
Expand Down
1 change: 1 addition & 0 deletions Sources/Slurp/Rx+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ extension ObservableType {

public func pipe<S: SlurpTask>(to: S) -> Observable<S.OutputType> {
return flatMap({ (element) -> Observable<S.OutputType> in
print("\n----- Running \(to.name) \n")
return to.onPipe(from: element)
})
}
Expand Down
6 changes: 4 additions & 2 deletions Sources/Slurp/Shell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Sources/Slurp/Slurp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class Slurp {
}

public func startWith<S: SlurpTask>(_ task: S) -> Observable<S.OutputType> {
print("\n----- Running \(task.name) \n")
return task.onPipe(from: ())
}

Expand Down
7 changes: 7 additions & 0 deletions Sources/SlurpXCTools/ApplicationLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
}

}

0 comments on commit 23aedea

Please sign in to comment.