File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change 1111
1212This package lets you capture subprocess ` stdout ` and ` stderr ` streams
1313independently, resynthesizing and colorizing the streams appropriately.
14+
15+ ## Installation
16+
17+ ` OutputCollectors.jl ` can be installed with [ Julia built-in package
18+ manager] ( https://julialang.github.io/Pkg.jl/v1/ ) . In a Julia session, after
19+ entering the package manager mode with ` ] ` , run the command
20+
21+ ```
22+ add OutputCollectors.jl
23+ ```
24+
25+ ## Usage
26+
27+ ``` julia
28+ julia> using OutputCollectors
29+
30+ julia> script = """
31+ #!/bin/sh
32+ echo 1
33+ sleep 1
34+ echo 2 >&2
35+ sleep 1
36+ echo 3
37+ sleep 1
38+ echo 4
39+ """
40+ " #!/bin/sh\n echo 1\n sleep 1\n echo 2 >&2\n sleep 1\n echo 3\n sleep 1\n echo 4\n "
41+
42+ julia> oc = OutputCollector (` sh -c $script ` ; verbose = true );
43+
44+ julia> [22 : 42 : 30 ] 1
45+ [22 : 42 : 31 ] 2
46+ [22 : 42 : 32 ] 3
47+ [22 : 42 : 33 ] 4
48+ julia>
49+
50+ julia> merge (oc)
51+ " 1\n 2\n 3\n 4\n "
52+
53+ julia> merge (oc; colored = true )
54+ " 1\n\e [31m2\n\e [39m3\n 4\n "
55+
56+ julia> tail (oc; len = 2 )
57+ " 3\n 4\n "
58+
59+ julia> collect_stdout (oc)
60+ " 1\n 3\n 4\n "
61+
62+ julia> collect_stderr (oc)
63+ " 2\n "
64+ ```
You can’t perform that action at this time.
0 commit comments