@tbrandenburg/node-red-cli 0.2.3 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
[](LICENSE)
|
|
5
5
|
[](package.json)
|
|
6
6
|
|
|
7
|
+
> Install the CLI with `npm install -g @tbrandenburg/node-red-cli`.
|
|
8
|
+
|
|
7
9
|
## Call Node-RED flows like Unix functions ⚡
|
|
8
10
|
|
|
9
11
|
`node-red-cli` explores a simple, powerful idea: existing Node-RED flows
|
|
@@ -21,7 +23,7 @@ By default only the resulting payload is printed as plain text. Pass
|
|
|
21
23
|
`--format=json` to print the full result object as JSON instead:
|
|
22
24
|
|
|
23
25
|
```bash
|
|
24
|
-
node
|
|
26
|
+
node-red-cli test/fixtures/flows.json calculate \
|
|
25
27
|
--set x=4 --set y=5 --format=json < /dev/null
|
|
26
28
|
```
|
|
27
29
|
|
|
@@ -118,8 +120,8 @@ make test
|
|
|
118
120
|
`make install` also wires up a `pre-push` git hook that runs `make ci`
|
|
119
121
|
(format, lint, and tests) automatically before every push.
|
|
120
122
|
|
|
121
|
-
To use `node-red-cli` as a regular command from a checkout
|
|
122
|
-
|
|
123
|
+
To use `node-red-cli` as a regular command from a repo checkout, install it
|
|
124
|
+
globally from the local source:
|
|
123
125
|
|
|
124
126
|
```bash
|
|
125
127
|
make install-global
|
|
@@ -128,7 +130,7 @@ make install-global
|
|
|
128
130
|
Try the CLI directly against the example flow:
|
|
129
131
|
|
|
130
132
|
```bash
|
|
131
|
-
echo '{"payload":{"x":4,"y":5}}' | node
|
|
133
|
+
echo '{"payload":{"x":4,"y":5}}' | node-red-cli test/fixtures/flows.json calculate
|
|
132
134
|
```
|
|
133
135
|
|
|
134
136
|
```
|
|
@@ -143,7 +145,7 @@ node, it is used automatically (with a warning on stderr if it also had to be
|
|
|
143
145
|
inferred across multiple tabs):
|
|
144
146
|
|
|
145
147
|
```bash
|
|
146
|
-
echo '{"payload":{"x":4,"y":5}}' | node
|
|
148
|
+
echo '{"payload":{"x":4,"y":5}}' | node-red-cli test/fixtures/single-link-in.flows.json
|
|
147
149
|
```
|
|
148
150
|
|
|
149
151
|
Instead of building the whole JSON message yourself, individual payload
|
|
@@ -153,7 +155,7 @@ becomes a number, `true` a boolean), otherwise kept as plain strings, and they
|
|
|
153
155
|
are applied on top of (and override) any payload read from stdin:
|
|
154
156
|
|
|
155
157
|
```bash
|
|
156
|
-
node
|
|
158
|
+
node-red-cli test/fixtures/flows.json calculate \
|
|
157
159
|
--set x=4 --set y=5 < /dev/null
|
|
158
160
|
```
|
|
159
161
|
|
|
@@ -176,7 +178,7 @@ to satisfy this CLI's file-based API. It is mutually exclusive with the
|
|
|
176
178
|
The flow is never written to disk in any of these forms.
|
|
177
179
|
|
|
178
180
|
```bash
|
|
179
|
-
node
|
|
181
|
+
node-red-cli --flow-json @test/fixtures/flows.json calculate \
|
|
180
182
|
--set x=4 --set y=5 < /dev/null
|
|
181
183
|
```
|
|
182
184
|
|
|
@@ -190,7 +192,7 @@ consumed by the flow definition instead, so `msg` must be built entirely from
|
|
|
190
192
|
`--set` params:
|
|
191
193
|
|
|
192
194
|
```bash
|
|
193
|
-
node
|
|
195
|
+
node-red-cli --flow-json - calculate --set x=4 --set y=5 \
|
|
194
196
|
< test/fixtures/flows.json
|
|
195
197
|
```
|
|
196
198
|
|
|
@@ -219,7 +221,7 @@ invocation and deletes it afterwards, so only the node types bundled with
|
|
|
219
221
|
invocation.
|
|
220
222
|
|
|
221
223
|
```bash
|
|
222
|
-
node
|
|
224
|
+
node-red-cli flows.json calculate \
|
|
223
225
|
--user-dir ~/.cache/node-red-cli \
|
|
224
226
|
--node-modules node-red-node-random \
|
|
225
227
|
--set x=4 --set y=5 < /dev/null
|