Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
staticfloat committed May 30, 2024
1 parent f2ee49f commit def2fd9
Showing 1 changed file with 11 additions and 31 deletions.
42 changes: 11 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,7 @@
[![codecov](https://codecov.io/gh/JuliaPackaging/OutputCollectors.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/JuliaPackaging/OutputCollectors.jl)


This package lets you capture subprocess `stdout` and `stderr` streams
independently, resynthesizing and colorizing the streams appropriately.

## Installation

`OutputCollectors.jl` can be installed with [Julia built-in package
manager](https://julialang.github.io/Pkg.jl/v1/). In a Julia session, after
entering the package manager mode with `]`, run the command

```
add OutputCollectors.jl
```
This package lets you capture subprocess `stdout` and `stderr` streams independently, resynthesizing and colorizing the streams appropriately.

## Usage

Expand All @@ -39,26 +28,17 @@ julia> script = """
"""
"#!/bin/sh\necho 1\nsleep 1\necho 2 >&2\nsleep 1\necho 3\nsleep 1\necho 4\n"

julia> oc = OutputCollector(`sh -c $script`; verbose = true);
julia> output = IOBuffer()
proc, oc = collect_output(`sh -c $script`, [output, stdout])
success(proc)

julia> [22:42:30] 1
[22:42:31] 2
[22:42:32] 3
[22:42:33] 4
julia>
1
2
3
4

julia> merge(oc)
"1\n2\n3\n4\n"

julia> merge(oc; colored = true)
"1\n\e[31m2\n\e[39m3\n4\n"

julia> tail(oc; len = 2)
"3\n4\n"
julia> wait(oc)

julia> collect_stdout(oc)
"1\n3\n4\n"

julia> collect_stderr(oc)
"2\n"
julia> String(take!(output))
"1\n2\n3\n4\n"
```

0 comments on commit def2fd9

Please sign in to comment.