CommandRunning

public protocol CommandRunning

Can run commands.

  • context Default implementation

    Undocumented

    Default Implementation

    Undocumented

    Declaration

    Swift

    var context: Context { get }
  • run(bash:combineOutput:) Extension method

    Runs a bash shell command.

    Declaration

    Swift

    @discardableResult
    public func run(bash bashcommand: String, combineOutput: Bool = false) -> RunOutput

    Parameters

    bashcommand

    the bash shell command.

    combineOutput

    if true then stdout and stderror go to the same stream. Default is false.

  • runAsync(bash:file:line:) Extension method

    Runs bash command and returns before it is finished.

    Declaration

    Swift

    public func runAsync(bash bashcommand: String, file: String = #file, line: Int = #line) -> AsyncCommand

    Parameters

    bashcommand

    the bash shell command.

  • Runs bash command and returns before it is finished. Any output is printed to standard output and standard error, respectively.

    Declaration

    Swift

    public func runAsyncAndPrint(bash bashcommand: String, file: String = #file, line: Int = #line) -> PrintedAsyncCommand

    Parameters

    bashcommand

    the bash shell command.

  • runAndPrint(bash:) Extension method

    Runs bash command and prints output and errors.

    Throws

    a CommandError.returnedErrorCode if the return code is anything but 0.

    Declaration

    Swift

    public func runAndPrint(bash bashcommand: String) throws

    Parameters

    bashcommand

    the bash shell command.

  • run(_:_:combineOutput:) Extension method

    Runs a command.

    Declaration

    Swift

    @discardableResult
    public func run(_ executable: String, _ args: Any..., combineOutput: Bool = false) -> RunOutput

    Parameters

    executable

    path to an executable, or the name of an executable in PATH.

    args

    the arguments, one string for each.

    combineOutput

    if true then stdout and stderror go to the same stream. Default is false.

  • runAsync(_:_:file:line:) Extension method

    Runs executable and returns before it is finished.

    Warning

    Application will be terminated if ‘executable’ could not be launched.

    Declaration

    Swift

    public func runAsync(_ executable: String, _ args: Any..., file: String = #file, line: Int = #line) -> AsyncCommand

    Parameters

    executable

    Path to an executable file. If not then exit.

    args

    Arguments to the executable.

  • Runs executable and returns before it is finished. Any output is printed to standard output and standard error, respectively.

    Warning

    Application will be terminated if ‘executable’ could not be launched.

    Declaration

    Swift

    public func runAsyncAndPrint(_ executable: String, _ args: Any..., file: String = #file, line: Int = #line) -> PrintedAsyncCommand

    Parameters

    executable

    Path to an executable file. If not then exit.

    args

    Arguments to the executable.

  • runAndPrint(_:_:) Extension method

    Runs executable and prints output and errors.

    Throws

    CommandError.returnedErrorCode(command: String, errorcode: Int) if the exit code is anything but 0.

    CommandError.inAccessibleExecutable(path: String) if ‘executable’ turned out to be not so executable after all.

    Declaration

    Swift

    public func runAndPrint(_ executable: String, _ args: Any...) throws

    Parameters

    executable

    path to an executable file.

    args

    arguments to the executable.