You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-19Lines changed: 16 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,19 +4,18 @@
4
4
5
5
Subprocess is a cross-platform package for spawning processes in Swift.
6
6
7
-
It's like [Foundation.Process](https://developer.apple.com/documentation/foundation/process), but written for Swift and build on top of structural concurrency.
8
-
9
7
10
8
## Getting Started
11
9
12
-
Subprocess uses [SwiftPM](https://swift.org/package-manager/) as its build tool, so we recommend using that as well. If you want to depend on Subprocess in your own project, it's as simple as adding a `dependencies` clause to your `Package.swift`:
10
+
To use `Subprocess` in a [SwiftPM](https://swift.org/package-manager/) project, add it as a package dependency to your `Package.swift`:
and then adding the `Subprocess` module to your target dependencies.
18
+
Then, adding the `Subprocess` module to your target dependencies:
20
19
21
20
```swift
22
21
.target(
@@ -124,7 +123,7 @@ let result = try await run(
124
123
125
124
`Subprocess` provides **platform-specific** configuration options, like setting `uid` and `gid` on Unix and adjusting window style on Windows, through the `PlatformOptions` struct. Check out the `PlatformOptions` documentation for a complete list of configurable parameters across different platforms.
126
125
127
-
Besides these platform-specific settings, `PlatformOptions` also includes an “escape hatch” via a closure. This closure allows you to have access to low level platformspecific spawning constructs to perform customizations if `Subprocess` doesn’t have higher-level APIs.
126
+
`PlatformOptions` also allows access to platform-specific spawning constructs and customizations via a closure.
128
127
129
128
```swift
130
129
importDarwin
@@ -153,7 +152,7 @@ let result = try await run(.path("/bin/exe"), platformOptions: platformOptions)
153
152
154
153
By default, `Subprocess`:
155
154
- Doesn’t send any input to the child process’s standard input
156
-
- Captures the child process’s standard output as a `String`, up to 128kb
155
+
- Captures the child process’s standard output as a `String`, up to 128kB
157
156
- Ignores the child process’s standard error
158
157
159
158
You can tailor how `Subprocess` handles the standard input, standard output, and standard error by setting the `input`, `output`, and `error` parameters:
@@ -168,7 +167,7 @@ let result = try await run(.name("cat"), input: .string(content, using: UTF8.sel
168
167
let result =tryawaitrun(.name("cat"), output: .data, error: .data)
169
168
```
170
169
171
-
`Subprocess`ships with these input options:
170
+
`Subprocess`supports these input options:
172
171
173
172
#### `NoInput`
174
173
@@ -178,7 +177,7 @@ Use it by setting `.none` for `input`.
178
177
179
178
#### `FileDescriptorInput`
180
179
181
-
This option reads input from a specified `FileDescriptor` you provide. If `closeAfterSpawningProcess` is set to `true`, the subprocess will close the file descriptor after spawning. If `false`, you need to close it, even if the subprocess fails to spawn.
180
+
This option reads input from a specified `FileDescriptor`. If `closeAfterSpawningProcess` is set to `true`, the subprocess will close the file descriptor after spawning. If `false`, you are responsible for closing it, even if the subprocess fails to spawn.
182
181
183
182
Use it by setting `.fileDescriptor(closeAfterSpawningProcess:)` for `input`.
184
183
@@ -214,7 +213,7 @@ Use it by setting `.asyncSequence` for `input`.
214
213
215
214
---
216
215
217
-
`Subprocess` also ships these output options:
216
+
`Subprocess` also supports these output options:
218
217
219
218
#### `DiscardedOutput`
220
219
@@ -247,10 +246,9 @@ This option redirects the child output to the `.standardOutput` or `.standardErr
247
246
248
247
### Cross-platform support
249
248
250
-
`Subprocess` works on all major platforms supported by Swift, including macOS, Linux, and Windows, with feature parity on all platforms as well as platform-specific options for each.
249
+
`Subprocess` works on macOS, Linux, and Windows, with feature parity on all platforms as well as platform-specific options for each.
251
250
252
-
The table below describes the current level of support that Subprocess has
253
-
for various platforms:
251
+
The table below describes the current level of support that Subprocess has for various platforms:
254
252
255
253
|**Platform**|**Support Status**|
256
254
|---|---|
@@ -278,13 +276,11 @@ swift package --disable-sandbox preview-documentation --target Subprocess
278
276
279
277
## Contributing to Subprocess
280
278
281
-
Subprocess is part of the Foundation project. We have a dedicated [Foundation Forum][forum] where people can ask and answer questions on how to use or work on this package. It's also a great place to discuss its evolution.
Subprocess is part of the Foundation project. Discussion and evolution take place on [Swift Foundation Forum](https://forums.swift.org/c/related-projects/foundation/99).
284
280
285
281
If you find something that looks like a bug, please open a [Bug Report][bugreport]! Fill out as many details as you can.
<palign="right">(<ahref="#readme-top">back to top</a>)</p>
290
286
@@ -298,8 +294,9 @@ Like all Swift.org projects, we would like the Subprocess project to foster a di
298
294
299
295
## Contact information
300
296
301
-
The current code owner of this package is Charles Hu ([@iCharlesHu](https://github.com/iCharlesHu)). You can contact him [on the Swift forums](https://forums.swift.org/u/icharleshu/summary).
297
+
The Foundation Workgroup communicates with the broader Swift community using the [forum](https://forums.swift.org/c/related-projects/foundation/99) for general discussions.
298
+
299
+
The workgroup can also be contacted privately by messaging [@foundation-workgroup](https://forums.swift.org/new-message?groupname=foundation-workgroup) on the Swift Forums.
302
300
303
-
In case of moderation issues, you can also directly contact a member of the [Swift Core Team](https://swift.org/community/#community-structure).
304
301
305
302
<palign="right">(<ahref="#readme-top">back to top</a>)</p>
0 commit comments