Functions
The following functions are available globally.
-
Runs a bash shell command.
Declaration
Swift
@discardableResult public func run(bash bashcommand: String, combineOutput: Bool = false) -> RunOutputParameters
bashcommandthe bash shell command.
combineOutputif true then stdout and stderror go to the same stream. Default is false.
-
Run bash command and return before it is finished.
Declaration
Swift
public func runAsync(bash bashcommand: String, file: String = #file, line: Int = #line) -> AsyncCommandParameters
bashcommandthe bash shell command.
Return Value
an AsyncCommand struct with standard output, standard error and a ‘finish’ function.
-
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) throwsParameters
bashcommandthe bash shell command.
-
Print message to standard error and halt execution.
Declaration
Swift
public func exit <T>(errormessage: T, errorcode: Int = 1, file: String = #file, line: Int = #line) -> NeverParameters
errormessagethe error message.
errorcodeexit code for the entire program. Defaults to 1.
Return Value
Never.
-
Print error to standard error and halt execution.
Declaration
Swift
public func exit(_ error: Error, file: String = #file, line: Int = #line) -> NeverParameters
errorthe error
Return Value
Never.
-
Undocumented
Declaration
Swift
public func == (e1: CommandError, e2: CommandError) -> Bool
-
Runs a command.
Declaration
Swift
@discardableResult public func run(_ executable: String, _ args: Any ..., combineOutput: Bool = false) -> RunOutputParameters
executablepath to an executable, or the name of an executable in PATH.
argsthe arguments, one string for each.
combineOutputif true then stdout and stderror go to the same stream. Default is false.
-
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) -> AsyncCommandParameters
executablepath to an executable file.
argsarguments to the executable.
Return Value
an AsyncCommand with standard output, standard error and a ‘finish’ function.
-
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 ...) throwsParameters
executablepath to an executable file.
argsarguments to the executable.
-
Append file or directory url to directory url
Declaration
Swift
public func + (leftpath: URL, rightpath: String) -> URL -
Open a file for reading, throw if an error occurs.
Declaration
Swift
public func open(_ path: String, encoding: String.Encoding = main.encoding) throws -> ReadableStream -
Open a file for reading, throw if an error occurs.
Declaration
Swift
public func open(_ path: URL, encoding: String.Encoding = main.encoding) throws -> ReadableStream -
Open a file for writing, create it first if it doesn’t exist. If the file already exists and overwrite=false, the writing will begin at the end of the file.
Declaration
Swift
public func open(forWriting path: URL, overwrite: Bool = false, encoding: String.Encoding = main.encoding) throws -> WritableStreamParameters
overwriteIf true, replace the file if it exists.
-
Open a file for writing, create it first if it doesn’t exist. If the file already exists and overwrite=false, the writing will begin at the end of the file.
Declaration
Swift
public func open(forWriting path: String, overwrite: Bool = false, encoding: String.Encoding = main.encoding) throws -> WritableStreamParameters
overwriteIf true, replace the file if it exists.
-
Creates a pair of streams. What is written to the 1st one can be read from the 2nd one.
Declaration
Swift
public func streams() -> (WritableStream, ReadableStream)
View on GitHub
Functions Reference