Skip to content

Commit 07953c2

Browse files
committed
Add documentation for the new closure based run()
1 parent d37e9f2 commit 07953c2

File tree

2 files changed

+51
-10
lines changed

2 files changed

+51
-10
lines changed

Sources/Subprocess/API.swift

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ public func run<
152152
/// - platformOptions: The platform specific options to use
153153
/// when running the executable.
154154
/// - input: The input to send to the executable.
155-
/// - output: How to manage the executable standard ouput.
156155
/// - error: How to manager executable standard error.
157156
/// - isolation: the isolation context to run the body closure.
158157
/// - body: The custom execution body to manually control the running process
@@ -205,6 +204,21 @@ public func run<Result, Input: InputProtocol, Error: OutputProtocol>(
205204
}
206205
}
207206

207+
/// Run a executable with given parameters and a custom closure
208+
/// to manage the running subprocess' lifetime and stream its standard error.
209+
/// - Parameters:
210+
/// - executable: The executable to run.
211+
/// - arguments: The arguments to pass to the executable.
212+
/// - environment: The environment in which to run the executable.
213+
/// - workingDirectory: The working directory in which to run the executable.
214+
/// - platformOptions: The platform specific options to use
215+
/// when running the executable.
216+
/// - input: The input to send to the executable.
217+
/// - output: How to manager executable standard output.
218+
/// - isolation: the isolation context to run the body closure.
219+
/// - body: The custom execution body to manually control the running process
220+
/// - Returns a ExecutableResult type containing the return value
221+
/// of the closure.
208222
public func run<Result, Input: InputProtocol, Output: OutputProtocol>(
209223
_ executable: Executable,
210224
arguments: Arguments = [],
@@ -252,6 +266,21 @@ public func run<Result, Input: InputProtocol, Output: OutputProtocol>(
252266
}
253267
}
254268

269+
/// Run a executable with given parameters and a custom closure
270+
/// to manage the running subprocess' lifetime, write to its
271+
/// standard input, and stream its standard output.
272+
/// - Parameters:
273+
/// - executable: The executable to run.
274+
/// - arguments: The arguments to pass to the executable.
275+
/// - environment: The environment in which to run the executable.
276+
/// - workingDirectory: The working directory in which to run the executable.
277+
/// - platformOptions: The platform specific options to use
278+
/// when running the executable.
279+
/// - error: How to manager executable standard error.
280+
/// - isolation: the isolation context to run the body closure.
281+
/// - body: The custom execution body to manually control the running process
282+
/// - Returns a ExecutableResult type containing the return value
283+
/// of the closure.
255284
public func run<Result, Error: OutputProtocol>(
256285
_ executable: Executable,
257286
arguments: Arguments = [],
@@ -282,6 +311,21 @@ public func run<Result, Error: OutputProtocol>(
282311
}
283312
}
284313

314+
/// Run a executable with given parameters and a custom closure
315+
/// to manage the running subprocess' lifetime, write to its
316+
/// standard input, and stream its standard error.
317+
/// - Parameters:
318+
/// - executable: The executable to run.
319+
/// - arguments: The arguments to pass to the executable.
320+
/// - environment: The environment in which to run the executable.
321+
/// - workingDirectory: The working directory in which to run the executable.
322+
/// - platformOptions: The platform specific options to use
323+
/// when running the executable.
324+
/// - output: How to manager executable standard output.
325+
/// - isolation: the isolation context to run the body closure.
326+
/// - body: The custom execution body to manually control the running process
327+
/// - Returns a ExecutableResult type containing the return value
328+
/// of the closure.
285329
public func run<Result, Output: OutputProtocol>(
286330
_ executable: Executable,
287331
arguments: Arguments = [],
@@ -313,17 +357,15 @@ public func run<Result, Output: OutputProtocol>(
313357
}
314358

315359
/// Run a executable with given parameters and a custom closure
316-
/// to manage the running subprocess' lifetime and write to its
317-
/// standard input via `StandardInputWriter`
360+
/// to manage the running subprocess' lifetime, write to its
361+
/// standard input, and stream its standard output and standard error.
318362
/// - Parameters:
319363
/// - executable: The executable to run.
320364
/// - arguments: The arguments to pass to the executable.
321365
/// - environment: The environment in which to run the executable.
322366
/// - workingDirectory: The working directory in which to run the executable.
323367
/// - platformOptions: The platform specific options to use
324368
/// when running the executable.
325-
/// - output:How to handle executable's standard output
326-
/// - error: How to handle executable's standard error
327369
/// - isolation: the isolation context to run the body closure.
328370
/// - body: The custom execution body to manually control the running process
329371
/// - Returns a ExecutableResult type containing the return value
@@ -464,11 +506,10 @@ public func run<
464506
/// Run a executable with given parameters specified by a `Configuration`
465507
/// - Parameters:
466508
/// - configuration: The `Subprocess` configuration to run.
467-
/// - output: The method to use for redirecting the standard output.
468-
/// - error: The method to use for redirecting the standard error.
469509
/// - isolation: the isolation context to run the body closure.
470510
/// - body: The custom configuration body to manually control
471-
/// the running process and write to its standard input.
511+
/// the running process, write to its standard input, stream
512+
/// its standard output and standard error.
472513
/// - Returns a ExecutableResult type containing the return value
473514
/// of the closure.
474515
public func run<Result>(

Sources/Subprocess/SubprocessFoundation/Input+Foundation.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ extension StandardInputWriter {
115115
}
116116

117117
/// Write a AsyncSequence of Data to the standard input of the subprocess.
118-
/// - Parameter sequence: The sequence of bytes to write.
118+
/// - Parameter asyncSequence: The sequence of bytes to write.
119119
/// - Returns number of bytes written.
120120
public func write<AsyncSendableSequence: AsyncSequence & Sendable>(
121121
_ asyncSequence: AsyncSendableSequence
@@ -135,7 +135,7 @@ extension TrackedFileDescriptor {
135135
) async throws -> Int {
136136
let fileDescriptor = self.fileDescriptor
137137
return try await withCheckedThrowingContinuation { continuation in
138-
// TODO: Figure out a better way to asynchornously write
138+
// TODO: Figure out a better way to asynchronously write
139139
DispatchQueue.global(qos: .userInitiated).async {
140140
data.withUnsafeBytes {
141141
Self.write(

0 commit comments

Comments
 (0)