Skip to content

Commit

Permalink
0.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
lihaoyi committed Nov 6, 2018
1 parent ee1dbed commit 8c48610
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.sc
Expand Up @@ -3,7 +3,7 @@ import mill._, scalalib._, publish._
object os extends Cross[OsModule]("2.11.12", "2.12.7")
class OsModule(val crossScalaVersion: String) extends CrossScalaModule with PublishModule{
def artifactName = "os-lib"
def publishVersion = "0.2.1"
def publishVersion = "0.2.2"
def pomSettings = PomSettings(
description = artifactName(),
organization = "com.lihaoyi",
Expand Down
6 changes: 3 additions & 3 deletions os/src/os/SubProcess.scala
Expand Up @@ -211,7 +211,7 @@ object SubProcess{

/**
* Represents the configuration of a SubProcess's input stream. Can either be
* [[os.Inherit]], [[os.Pipe]], [[os.Redirect]] or a [[os.Source]]
* [[os.Inherit]], [[os.Pipe]], [[os.Path]] or a [[os.Source]]
*/
trait ProcessInput{
def redirectFrom: ProcessBuilder.Redirect
Expand All @@ -234,14 +234,14 @@ object ProcessInput{

/**
* Represents the configuration of a SubProcess's output or error stream. Can
* either be [[os.Inherit]], [[os.Pipe]], [[os.Redirect]] or a [[os.ProcessOutput]]
* either be [[os.Inherit]], [[os.Pipe]], [[os.Path]] or a [[os.ProcessOutput]]
*/
sealed trait ProcessOutput{
def redirectTo: ProcessBuilder.Redirect
def processOutput(out: => SubProcess.OutputStream): Option[Runnable]
}
object ProcessOutput{
implicit def makePathRedirect(p: Path): ProcessInput = PathRedirect(p)
implicit def makePathRedirect(p: Path): ProcessOutput = PathRedirect(p)

def apply(f: (Array[Byte], Int) => Unit, preReadCallback: () => Unit = () => ()) =
CallbackOutput(f, preReadCallback)
Expand Down
5 changes: 5 additions & 0 deletions os/test/src/test/os/SpawningSubprocessesTests.scala
Expand Up @@ -49,6 +49,11 @@ object SpawningSubprocessesTests extends TestSuite {
val hash = os.proc("shasum", "-a", "256").call(stdin = "Hello World")
hash.out.trim ==> "a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e -"

// Taking input from a file and directing output to another file
os.proc("base64").call(stdin = wd / "File.txt", stdout = wd / "File.txt.b64")

os.read(wd / "File.txt.b64") ==> "SSBhbSBjb3c=\n"

if (false){
os.proc("vim").call(stdin = os.Inherit, stdout = os.Inherit, stderr = os.Inherit)
}
Expand Down
11 changes: 8 additions & 3 deletions readme.md
Expand Up @@ -133,9 +133,9 @@ To begin using OS-Lib, first add it as a dependency to your project's build:

```scala
// SBT
"com.lihaoyi" %% "os-lib" % "0.2.0"
"com.lihaoyi" %% "os-lib" % "0.2.2"
// Mill
ivy"com.lihaoyi::os-lib:0.2.0"
ivy"com.lihaoyi::os-lib:0.2.2"
```

## Cookbook
Expand Down Expand Up @@ -1286,6 +1286,11 @@ assert(fail.err.string.contains("No such file or directory"))
// You can pass in data to a subprocess' stdin
val hash = os.proc("shasum", "-a", "256").call(stdin = "Hello World")
hash.out.trim ==> "a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e -"

// Taking input from a file and directing output to another file
os.proc("base64").call(stdin = wd / "File.txt", stdout = wd / "File.txt.b64")

os.read(wd / "File.txt.b64") ==> "SSBhbSBjb3c="
```

If you want to spawn an interactive subprocess, such as `vim`, `less`, or a
Expand Down Expand Up @@ -1738,7 +1743,7 @@ string, int or set representations of the `os.PermSet` via:

## Changelog

### 0.2.1
### 0.2.2

- Allow chaining of multiple subprocesses `stdin`/`stdout`

Expand Down

0 comments on commit 8c48610

Please sign in to comment.