CommandsPipeline type

Undocumented

Methods

$()(cp:CommandsPipeline) Source: stdlib.ngs:4813
Run external processes described by the commands pipeline. Waits for the commands to finish unless "&" is specified.

Automatically called by NGS for syntax

$(my_prog) , $(some | programs)

Returns

Process

Example

if $(test -f /myfile) { ... }
# or
p = $(node main.js serve &)
YOUR_TESTS_OF_NODE_SERVER_HERE
p.kill()
%()(cp:CommandsPipeline) Source: stdlib.ngs:5040
Returns cp, wihout any processing. Convenient way to pass ready-to-run Command as an argument

Automatically called by NGS for syntax

%(my_command) , %(my_command | my_other_command)

Example

F run_when_needed(cp:CommandsPipeline) { ... $(cp) ... }
...
run_when_needed(%(ls >/tmp/my_ls))
``(cp:CommandsPipeline) Source: stdlib.ngs:4935
Get command standard output. Similar to bash. Does not strip trailing new line character(s) `line:true my_command` will return the first line, stripping trailing new line character(s)

Automatically called by NGS for syntax

`my_command` , `my_command | my_other_command`
````(cp:CommandsPipeline) Source: stdlib.ngs:4950
Get command standard output and decode() it.

Automatically called by NGS for syntax

``my_command`` , ``my_command | my_other_command``

Returns

structured data when the output can be parsed.

Example

``aws ec2 describe-instances`` is Arr  # true
``aws ec2 describe-instances``.InstanceId.map(X[0..3]).join(",")  # i-3, i-9, i-8, i-a, i-7, ...
assert_exit_code(cp:CommandsPipeline, expected:Int, title:Str=null) Source: autoload/test.ngs:165
Assert process exits with the specified exit code. Throws TestFail.

Returns

cp

Example

p = $(true); assert_exit_code(p, 0)   # OK
p = $(false); assert_exit_code(p, 1)  # OK
p = $(false); assert_exit_code(p, 0)  # Throws TestFail
assert_output_has(cp:CommandsPipeline, expected:RegExp, title:Str=null) Source: autoload/test.ngs:178
Assert process has given output. Throws TestFail.

Example

assert_output_has($(echo abc), /xyz/)        # Throws TestFail
p = $(echo abc); assert_output_has(p, /c$/)  # OK
assert_output_has(cp:CommandsPipeline, expected:Str, title:Str=null) Source: autoload/test.ngs:189
Assert process has given output. Throws TestFail.

Example

assert_output_has($(echo abc), "xyz")        # Throws TestFail
p = $(echo abc); assert_output_has(p, "bc")  # OK
Bool(cp:CommandsPipeline) Source: stdlib.ngs:4560
Wait for all process to finish and see whether all exit codes are 0

Returns

Bool

Example

if $(test -f myfile) ... # if runs Bool() on any non-Bool condition expression
close(cp:CommandsPipeline) Source: stdlib.ngs:4914
Close reading and writing pipes of CommandsPipeline, if they exist
ExitCode(cp:CommandsPipeline) Source: stdlib.ngs:4601
Convert CommandsPipeline to exit code. Waits for the processes to finish. Returns first non-zero exit code. Returns zero if all exit codes are zero.
inspect(cp:CommandsPipeline) Source: stdlib.ngs:5699
Undocumented
kill(cp:CommandsPipeline, sig:Int=15) Source: stdlib.ngs:4983
Kill all processes in the CommandsPipeline. Throws InvalidArgument if CommandsPipeline is not running (yet).
lines(cp:CommandsPipeline) Source: stdlib.ngs:5062
Wait for cp and return lines of stdout of the last process.

Returns

Arr of Str

Example

$(seq 3 | tac).lines().map(Int)  # [3,2,1]
lines(cp:CommandsPipeline, cb:Fun) Source: stdlib.ngs:5070
Wait for cp and return call cb for each line of stdout of last process. Warning: current implementation waits for the processes to finish, accumulates all stdout of the last process, and only then starts calling cb for each line.

Returns

Arr of Str
read(cp:CommandsPipeline, count:Any=null) Source: stdlib.ngs:4906
Read from last process of CommandsPipeline

Example

p = $(seq 3 | tac |);
data = read(p);
p.close()
run(r:AWS::Res, log_pfx:Str, cp:CommandsPipeline, do_decode:Any=true)internal Source: autoload/AWS.ngs:120
Run a command. Internal method. Please do not use outside the AWS library.
run(rd:AWS::ResDef, log_pfx:Str, cp:CommandsPipeline, do_decode:Any=true)internal Source: autoload/AWS.ngs:190
Run an external command related to the resource definition. Will not run the command if rd.dry_run is true.

Parameters

do_decodeWhether to decode the output

Returns

Either parsed output or finished CommandsPipeline (processes in CommandsPipeline finished)
run(r:AWS2::Res, log_pfx:Str, cp:CommandsPipeline, do_decode:Any=true)internal Source: autoload/AWS2.ngs:129
Run a command. Internal method. Please do not use outside the AWS library.
run(rd:AWS2::ResDef, log_pfx:Str, cp:CommandsPipeline, do_decode:Any=true)internal Source: autoload/AWS2.ngs:194
Run an external command related to the resource definition. Will not run the command if rd.dry_run is true.

Parameters

do_decodeWhether to decode the output

Returns

Either parsed output or finished CommandsPipeline (processes in CommandsPipeline finished)
Str(cp:CommandsPipeline) Source: stdlib.ngs:4612
Wait for the processes to finish and return standard output of the last process in pipeline.

Returns

Str
wait(cp:CommandsPipeline) Source: stdlib.ngs:4593
Wait for all processes to finish.
write(cp:CommandsPipeline, s:Str) Source: stdlib.ngs:4896
Write to first process of CommandsPipeline

Example

p = (|cat -n | tac >/tmp/1)
p.write("one\n")
p.write("two\n")
p.close()