Skip to content

Commit

Permalink
Correct readme
Browse files Browse the repository at this point in the history
  • Loading branch information
akash-akya committed Apr 19, 2023
1 parent 9829789 commit 67d3802
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,23 @@ end

Run a command and read from stdout

```
```elixir
iex> Exile.stream!(~w(echo Hello))
...> |> Enum.into("") # collect as string
"Hello\n"
```

Run a command with list of strings as input

```
```elixir
iex> Exile.stream!(~w(cat), input: ["Hello", " ", "World"])
...> |> Enum.into("") # collect as string
"Hello World"
```

Run a command with input as Stream

```
```elixir
iex> input_stream = Stream.map(1..10, fn num -> "#{num} " end)
iex> Exile.stream!(~w(cat), input: input_stream)
...> |> Enum.into("")
Expand All @@ -63,7 +63,7 @@ end

Run a command with input as infinite stream

```
```elixir
# create infinite stream
iex> input_stream = Stream.repeatedly(fn -> "A" end)
iex> binary =
Expand All @@ -77,7 +77,7 @@ end

Run a command with input Collectable

```
```elixir
# Exile calls the callback with a sink where the process can push the data
iex> Exile.stream!(~w(cat), input: fn sink ->
...> Stream.map(1..10, fn num -> "#{num} " end)
Expand All @@ -91,7 +91,7 @@ end

When the command wait for the input stream to close

```
```elixir
# base64 command wait for the input to close and writes data to stdout at once
iex> Exile.stream!(~w(base64), input: ["abcdef"])
...> |> Enum.into("")
Expand All @@ -100,15 +100,15 @@ end

When the command exit with an error

```
```elixir
iex> Exile.stream!(["sh", "-c", "exit 4"])
...> |> Enum.into("")
** (Exile.Process.Error) command exited with status: 4
```

With `max_chunk_size` set

```
```elixir
iex> data =
...> Exile.stream!(~w(cat /dev/urandom), max_chunk_size: 100, ignore_epipe: true)
...> |> Stream.take(5)
Expand All @@ -119,7 +119,7 @@ end

When input and output run at different rate

```
```elixir
iex> input_stream = Stream.map(1..1000, fn num -> "X #{num} X\n" end)
iex> Exile.stream!(~w(grep 250), input: input_stream)
...> |> Enum.into("")
Expand All @@ -128,7 +128,7 @@ end

With stderr enabled

```
```elixir
iex> Exile.stream!(["sh", "-c", "echo foo\necho bar >> /dev/stderr"], enable_stderr: true)
...> |> Enum.to_list()
[{:stdout, "foo\n"}, {:stderr, "bar\n"}]
Expand Down

0 comments on commit 67d3802

Please sign in to comment.