 import Foundation
 
+/// The result of a task execution
 public typealias ChoreResult = (result: Int32, stdout: String, stderr: String)
 
 private func string_trim(string: NSString!) -> String {

    return (0, right(left.stdout), "")
}

public func | (left: (() -> String), right: String) -> ChoreResult {
    return (0, left(), "")|right
}

public func | (left: (() -> String), right: [String]) -> ChoreResult {
    return (0, left(), "")|right
}

public func | (left: String, right: String) -> ChoreResult {
    return (0, left, "")|right
}

public func | (left: String, right: [String]) -> ChoreResult {
    return (0, left, "")|right
}


infix operator | {}

/**
Executes a command with standard input from another command.

:param: left The result of a previous command.
:param: right The command to execute.
:returns: A tuple containing the exit code, stdout and stderr output.
*/
public func | (left: ChoreResult, right: String) -> ChoreResult {
    return left|[right]
}

/**
Executes a command with standard input from another command.

:param: left The result of a previous command.
:param: right The command to execute and its arguments.
:returns: A tuple containing the exit code, stdout and stderr output.
*/
public func | (left: ChoreResult, right: [String]) -> ChoreResult {
    if left.result != 0 {
        return left
