CommandRunning

public protocol CommandRunning

Can run commands.

  • context Default implementation

    Undocumented

    Default Implementation

    Undocumented

    Declaration

    Swift

    public protocol CommandRunning
  • 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

    Run bash command and return 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.

    Return Value

    an AsyncCommand struct with standard output, standard error and a ‘finish’ function.

  • runAndPrint(bash:) Extension method

    Run bash command and print 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

    Run executable and return before it is finished.

    Warning

    will crash 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.

    Return Value

    An AsyncCommand with standard output, standard error and a ‘finish’ function.

  • runAndPrint(_:_:) Extension method

    Run executable and print 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.