nushell/crates/nu_plugin_stream_example
2024-03-05 21:28:40 +01:00
..
src Bidirectional communication and streams for plugins (#11911) 2024-02-25 16:32:50 -06:00
Cargo.toml Bump version for 0.91.0 release (#12070) 2024-03-05 21:28:40 +01:00
README.md Bidirectional communication and streams for plugins (#11911) 2024-02-25 16:32:50 -06:00

Streaming Plugin Example

Crate with a simple example of the StreamingPlugin trait that needs to be implemented in order to create a binary that can be registered into nushell declaration list

stream_example seq

This command demonstrates generating list streams. It generates numbers from the first argument to the second argument just like the builtin seq command does.

Examples:

stream_example seq 1 10
[1 2 3 4 5 6 7 8 9 10]
stream_example seq 1 10 | describe
list<int> (stream)

stream_example sum

This command demonstrates consuming list streams. It consumes a stream of numbers and calculates the sum just like the builtin math sum command does.

Examples:

seq 1 5 | stream_example sum
15

stream_example collect-external

This command demonstrates transforming streams into external streams. The list (or stream) of strings on input will be concatenated into an external stream (raw input) on stdout.

[Hello "\n" world how are you] | stream_example collect-external
Hello
worldhowareyou