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
Add lightweight syntax for os.proc().call() and os.proc().spawn() (#292)
Now these can be spelled `os.call()` and `os.spawn()`, and we provide
`Shellable[TupleN]` conversions to make it convenient to call without
constructing a `Seq(...)` every time. So this:
```scala
os.proc("ls", "doesnt-exist").call(cwd = wd, check = false, stderr = os.Pipe)
```
Becomes
```scala
os.call(cmd = ("ls", "doesnt-exist"), cwd = wd, check = false, stderr = os.Pipe)
```
The original purpose of the `os.proc().call()` style was to avoid the
verbosity of constructing a `Seq` each time, and by making it flexible
enough to take tuples, this mitigates that issue without the annoying
method chaining style.
The new style still isn't actually shorter in terms of number of
characters, but it is a lot cleaner in terms of "function call taking
named/optional arguments" rather than "fluent call chain with first call
taking varargs and second call taking named/optional parameters". It
also aligns with the Python `subprocess.*` functions which OS-Lib in
general is inspired by
To support Scala 2, the `Shellable[TupleN]` conversions are defined
using codegen. Scala 3 allows a nicer generic-tuple implementation, but
we'll be supporting Scala 2 for the foreseeable future.
The older `os.proc.*` APIs remain, both for backwards compatibility, as
well as to support the `pipeTo` API used to construct process pipelines
Duplicated some of the existing subprocess tests to exercise the new
APIs. Did not duplicate all of them, as the new APIs are pretty dumb
forwarders to the existing ones so we don't need to exercise every flag
in detail.
Updated the docs to point towards the new APIs, but with a mention that
the older `os.proc().call()` style is still supported
0 commit comments