@sndwrks/osc-cli 1.0.3 → 1.3.0

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/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright © 2026 sndwrks Inc
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,144 +1,330 @@
1
- # OSC CLI Tool
1
+ ![sndwrks logo](images/sndwrks-square_200px-high.png)
2
2
 
3
- **DISCLAIMER: this was written by AI, but it will be maintained by humans (probably)**
3
+ # osc-cli
4
4
 
5
- A simple command-line application for sending and receiving OSC (Open Sound Control) messages via TCP and UDP.
5
+ ![NPM Version](https://img.shields.io/npm/v/%40sndwrks%2Fosc-cli?style=flat-square&color=rgb(239%2C%20145%2C%2081))
6
+ ![GitHub License](https://img.shields.io/github/license/sndwrks/osc-cli?style=flat&color=rgb(14%2C%2022%2C%2025))
7
+ ![Node LTS](https://img.shields.io/node/v-lts/%40sndwrks%2Fosc-cli)
6
8
 
7
- ## Features
9
+
10
+
11
+ **DISCLAIMER: this was written by AI, and promptly rewritten, but it will be maintained by humans (probably).**
12
+
13
+ A simple command-line application for sending and receiving OSC (Open Sound Control) messages via TCP and UDP including load testing.
14
+
15
+ ## What does it do?
8
16
 
9
17
  - Listen for OSC messages via UDP
10
18
  - Listen for OSC messages via TCP
11
19
  - Listen on both protocols simultaneously
12
20
  - Send OSC messages via UDP
13
21
  - Send OSC messages via TCP
14
- - Logging with @sndwrks/lumberjack
15
- - **Installable as a global CLI tool**
22
+ - Load Testing with UDP
23
+ - Load Testing with TCP
24
+ - Integration Testing with UDP (send to app, validate response)
25
+ - Integration Testing with TCP (send to app, validate response)
16
26
 
17
27
  ## Installation
18
28
 
19
- ### Install Globally
20
-
21
- ```bash
22
- npm install -g .
23
- ```
24
-
25
- After installation, you can use the `osc-cli` command from anywhere:
29
+ ### Install from npm
26
30
 
27
31
  ```bash
28
- osc-cli listen-udp 8000
32
+ npm install -g @sndwrks/osc-cli
29
33
  ```
30
34
 
31
- ### Install as Dependency
35
+ ### Install from Github
32
36
 
33
37
  ```bash
34
- npm install
35
- ```
38
+ # clone the repo
39
+ git clone git@github.com:sndwrks/osc-cli.git
36
40
 
37
- ### Install from npm
41
+ # install globally
42
+ npm i -g .
38
43
 
39
- ```bash
40
- npm install -g @sndwrks/osc-cli
44
+ # otherwise build and run locally
45
+ npm i
46
+ npm run build
47
+ npm start -- <commands>
41
48
  ```
42
49
 
43
- ## Build
50
+ ## Uninstall
44
51
 
45
52
  ```bash
46
- npm run build
53
+ npm uninstall -g osc-cli
47
54
  ```
48
55
 
49
56
  ## Usage
50
57
 
51
- Once installed globally, use the `osc-cli` command. If not installed globally, use `npm start` instead.
58
+ Once installed globally, use `osc-cli <command>`. If not installed globally, use `npm start -- <command>` instead.
52
59
 
53
- ```bash
54
- npm start -- listen-udp <port>
55
- npm start -- listen-tcp <port>
56
- npm start -- listen-both <udp-port> <tcp-port>
57
- ```
58
60
 
59
61
  ### Listen for OSC Messages
60
62
 
61
- **UDP (default port 57121):**
63
+ Starts a server to listen for incoming OSC messages.
64
+
65
+ #### Args
66
+
67
+ | Flag | Option | Type | Description | Example | Default |
68
+ |------|--------|------|-------------|---------|---------|
69
+ | `-i` | `--ip-address <ip-address>` | string | IP address to bind to | 127.0.0.1 | 0.0.0.0 |
70
+ | `-p` | `--port <port>` | number | Port the server listens on | 53000 | 51000 |
71
+
72
+ **UDP (default port 51000):**
62
73
  ```bash
63
74
  osc-cli listen-udp
64
- osc-cli listen-udp 8000
75
+ osc-cli listen-udp -p 8000
76
+ osc-cli listen-udp --port 8000 --ip-address 127.0.0.1
65
77
  ```
66
78
 
67
- **TCP (default port 57122):**
79
+ **TCP (default port 51001):**
68
80
  ```bash
69
81
  osc-cli listen-tcp
70
- osc-cli listen-tcp 8001
82
+ osc-cli listen-tcp -p 8001
83
+ osc-cli listen-tcp --port 8001 --ip-address 127.0.0.1
71
84
  ```
72
85
 
73
86
  **Both UDP and TCP:**
74
87
  ```bash
75
88
  osc-cli listen-both
76
- osc-cli listen-both 8000 8001
89
+ osc-cli listen-both --udp-port 8000 --tcp-port 8001
90
+ osc-cli listen-both --udp-port 8000 --tcp-port 8001 --udp-ip-address 127.0.0.1 --tcp-ip-address 127.0.0.1
77
91
  ```
78
92
 
79
93
  ### Send OSC Messages
80
94
 
95
+ Send a single OSC message.
96
+
97
+ #### Args
98
+
99
+ Sends a single OSC message via UDP
100
+
101
+ | Flag | Option | Type | Description | Example | Default |
102
+ |------|--------|------|-------------|---------|---------|
103
+ | | `--udp-ip-address <udp-ip-address>` | string | IP address to bind the UDP server to | 127.0.0.1 | |
104
+ | | `--udp-port <udp-port>` | number | Port the UDP server will listen on | 53000 | 51000 |
105
+ | | `--tcp-ip-address <tcp-ip-address>` | string | IP address to bind the TCP server to | 127.0.0.1 | 0.0.0.0 |
106
+ | | `--tcp-port <tcp-port>` | number | Port the TCP server will listen on | 53001 | 51001 |
107
+
108
+
81
109
  **UDP:**
82
110
  ```bash
83
- osc-cli send-udp /test hello 123 127.0.0.1 57121
84
- osc-cli send-udp /synth/note 440 0.5 localhost 8000
111
+ # no args
112
+ osc-cli send-udp -a /test -i 127.0.0.1 -p 57121
113
+
114
+ # with args
115
+ osc-cli send-udp -a /test -i 127.0.0.1 -p 57121 --args hello 123
116
+ osc-cli send-udp --address /synth/note --ip-address localhost --port 8000 --args 440 0.5
85
117
  ```
86
118
 
87
119
  **TCP:**
88
- NOTE: This is currently broken due to issue in osc.js
89
120
  ```bash
90
- osc-cli send-tcp /test hello 123 127.0.0.1 57122
91
- osc-cli send-tcp /synth/note 440 0.5 localhost 8001
121
+ osc-cli send-tcp -a /test -i 127.0.0.1 -p 57122 --args hello 123
122
+ osc-cli send-tcp --address /synth/note --ip-address localhost --port 8001 --args 440 0.5
92
123
  ```
93
124
 
94
- ## Message Format
125
+ ### Load Testing
126
+
127
+ The load testing allows for sending multiple messages in batches. The batches may overlap if the message rate is slower than the batch interval.
95
128
 
96
- - **Address**: OSC address pattern (e.g., `/test`, `/synth/freq`)
97
- - **Args**: Space-separated values (automatically parsed as numbers if possible)
98
- - **Host**: Target hostname or IP address (default: 127.0.0.1)
99
- - **Port**: Target port number
129
+ #### Args
100
130
 
101
- ## Examples
131
+ | Flag | Option | Type | Required | Description | Example | Default |
132
+ |------|--------|------|----------|-------------|---------|---------|
133
+ | | `--local-ip-address <local-ip-address>` | string | No | Local IP Address to bind the client to | | 0.0.0.0 |
134
+ | | `--local-port <local-port>` | number | No | Local port to bind the client to | | 51000 |
135
+ | | `--remote-ip-address <remote-ip-address>` | string | Yes | IP Address to send the messages to | 10.10.209.5 | |
136
+ | | `--remote-port <remote-port>` | number | Yes | Port to send the messages to | | |
137
+ | | `--messages-per-batch <messages-per-batch>` | number | Yes | The number of messages per batch to send | | |
138
+ | | `--message-rate <message-rate>` | number | No | The number of messages to send per second | | |
139
+ | | `--total-batches <total-batches>` | number | Yes | The total number of batches to send | | |
140
+ | | `--batch-interval <batch-interval>` | number | Yes | The time in seconds between batches | | |
141
+ | | `--custom-address <custom-address>` | string | No | A custom address to send | | /sndwrks/osc-cli-load-tester/test |
102
142
 
143
+ **UDP Load Test:**
103
144
  ```bash
104
- # Install globally
105
- npm install -g .
145
+ # minimal required args
146
+ osc-cli osc-load-test-udp \
147
+ --remote-ip-address 127.0.0.1 \
148
+ --remote-port 8000 \
149
+ --messages-per-batch 100 \
150
+ --total-batches 10 \
151
+ --batch-interval 1
152
+ ```
106
153
 
107
- # Start listening on UDP port 8000
108
- osc-cli listen-udp 8000
154
+ ```bash
155
+ # with optional args
156
+ osc-cli osc-load-test-udp \
157
+ --remote-ip-address 10.10.209.5 \
158
+ --remote-port 8000 \
159
+ --messages-per-batch 100 \
160
+ --total-batches 10 \
161
+ --batch-interval 1 \
162
+ --message-rate 50
163
+ ```
109
164
 
110
- # In another terminal, send a message
111
- osc-cli send-udp /hello world 127.0.0.1 8000
165
+ ```bash
166
+ osc-cli osc-load-test-udp \
167
+ --local-ip-address 0.0.0.0 \
168
+ --local-port 51000 \
169
+ --remote-ip-address 10.10.209.5 \
170
+ --remote-port 8000 \
171
+ --messages-per-batch 100 \
172
+ --message-rate 50 \
173
+ --total-batches 10 \
174
+ --batch-interval 1 \
175
+ --custom-address /my/custom/address
176
+ ```
112
177
 
113
- # Listen on both protocols
114
- osc-cli listen-both 9000 9001
178
+ **TCP Load Test:**
179
+ ```bash
180
+ # minimal required args
181
+ osc-cli osc-load-test-tcp \
182
+ --remote-ip-address 127.0.0.1 \
183
+ --remote-port 8001 \
184
+ --messages-per-batch 100 \
185
+ --total-batches 10 \
186
+ --batch-interval 1
187
+ ```
115
188
 
116
- # Send via TCP
117
- osc-cli send-tcp /synth/freq 440 127.0.0.1 9001
189
+ ```bash
190
+ # with optional args
191
+ osc-cli osc-load-test-tcp \
192
+ --remote-ip-address 10.10.209.5 \
193
+ --remote-port 8001 \
194
+ --messages-per-batch 100 \
195
+ --total-batches 10 \
196
+ --batch-interval 1 \
197
+ --message-rate 50
118
198
  ```
119
199
 
120
- ## Development
200
+ ```bash
201
+ # with all args
202
+ osc-cli osc-load-test-tcp \
203
+ --local-ip-address 0.0.0.0 \
204
+ --local-port 51000 \
205
+ --remote-ip-address 10.10.209.5 \
206
+ --remote-port 8001 \
207
+ --messages-per-batch 100 \
208
+ --message-rate 50 \
209
+ --total-batches 10 \
210
+ --batch-interval 1 \
211
+ --custom-address /my/custom/address
212
+ ```
121
213
 
122
- If you haven't installed globally, you can use npm scripts:
214
+ ### Integration Testing
215
+
216
+ Integration testing commands send messages to a remote application and validate the responses. The remote application should echo back OSC messages to the local listener port.
217
+
218
+ #### Args
219
+
220
+ | Flag | Option | Type | Required | Description | Example | Default |
221
+ |------|--------|------|----------|-------------|---------|---------|
222
+ | `-i` | `--remote-ip-address <ip>` | string | Yes | Remote IP to send messages to | 10.10.209.5 | |
223
+ | `-p` | `--remote-port <port>` | number | Yes | Remote port to send messages to | 8000 | |
224
+ | | `--mode <mode>` | string | Yes | Test mode: "single" or "load" | single | |
225
+ | | `--local-ip-address <ip>` | string | No | Local IP to listen for responses | | 0.0.0.0 |
226
+ | | `--local-port <port>` | number | No | Local port to listen for responses | | 57120 (UDP) / 57121 (TCP) |
227
+ | `-a` | `--address <address>` | string | No | OSC address to send | /test | /test |
228
+ | | `--args <args...>` | string[] | No | Arguments to send | hello 123 | |
229
+ | | `--expected-address <address>` | string | No | Expected response address | /response | sent address |
230
+ | | `--expected-args <args...>` | string[] | No | Expected response args | ok 1 | sent args |
231
+ | | `--timeout <ms>` | number | No | Response timeout | | 5000 |
232
+ | | `--messages-per-batch <n>` | number | No | Messages per batch (load mode) | | |
233
+ | | `--total-batches <n>` | number | No | Total batches (load mode) | | |
234
+ | | `--batch-interval <seconds>` | number | No | Interval between batches (load mode) | | |
235
+ | | `--message-rate <n>` | number | No | Messages per second (load mode) | | |
236
+
237
+ **UDP Integration Test (single message):**
238
+ ```bash
239
+ # Send a message and validate the response matches
240
+ osc-cli test-osc-udp \
241
+ --mode single \
242
+ -i 127.0.0.1 \
243
+ -p 8000 \
244
+ -a /test \
245
+ --args hello 123
246
+
247
+ # With custom expected response
248
+ osc-cli test-osc-udp \
249
+ --mode single \
250
+ -i 127.0.0.1 \
251
+ -p 8000 \
252
+ -a /ping \
253
+ --expected-address /pong \
254
+ --expected-args ok
255
+ ```
123
256
 
257
+ **UDP Integration Test (load test):**
124
258
  ```bash
125
- npm run build # Build TypeScript
126
- npm start listen-udp # Run with npm start
259
+ # Load test with throughput validation
260
+ osc-cli test-osc-udp \
261
+ --mode load \
262
+ -i 127.0.0.1 \
263
+ -p 8000 \
264
+ --messages-per-batch 100 \
265
+ --total-batches 10 \
266
+ --batch-interval 1
127
267
  ```
128
268
 
129
- ## Uninstall
269
+ **TCP Integration Test (single message):**
270
+ ```bash
271
+ osc-cli test-osc-tcp \
272
+ --mode single \
273
+ -i 127.0.0.1 \
274
+ -p 8001 \
275
+ -a /test \
276
+ --args hello 123
277
+ ```
130
278
 
279
+ **TCP Integration Test (load test):**
131
280
  ```bash
132
- npm uninstall -g osc-cli
281
+ osc-cli test-osc-tcp \
282
+ --mode load \
283
+ -i 127.0.0.1 \
284
+ -p 8001 \
285
+ --messages-per-batch 50 \
286
+ --total-batches 5 \
287
+ --batch-interval 2 \
288
+ --message-rate 100
133
289
  ```
134
290
 
135
- ## Publishing to NPM
291
+ **Exit codes:**
292
+ - `0` - Test passed (single: response matched; load: no dropped messages)
293
+ - `1` - Test failed (timeout, mismatch, or dropped messages)
294
+
295
+ ## Development
136
296
 
137
- See [PUBLISHING.md](PUBLISHING.md) for detailed instructions on how to publish this package to npm with the TypeScript build step.
297
+ Please get in there if you want. This repo uses eslint 8 for linting AND code style.
298
+
299
+ **VSCode Example Settings**
300
+ ```json
301
+ {
302
+ "editor.formatOnSave": true,
303
+ "eslint.codeActionsOnSave.rules": null,
304
+ "eslint.validate": [
305
+ "typescript"
306
+ ],
307
+ "[typescript]": {
308
+ "editor.tabSize": 2,
309
+ "editor.formatOnSave": true,
310
+ "editor.codeActionsOnSave": {
311
+ "source.fixAll.eslint": "explicit"
312
+ }
313
+ },
314
+ "eslint.format.enable": true,
315
+ "editor.defaultFormatter": "dbaeumer.vscode-eslint",
316
+ "editor.tabSize": 2,
317
+ "javascript.updateImportsOnFileMove.enabled": "always",
318
+ "editor.rulers": [100]
319
+ }
320
+ ```
138
321
 
139
- ## Dependencies
322
+ ```bash
323
+ npm run build
324
+ npm start listen-udp -- <args>
325
+ ```
140
326
 
141
- - `osc`: OSC protocol implementation
142
- - `@sndwrks/lumberjack`: Winston-based logging library
327
+ ## Wants and Desires
143
328
 
144
- **Note:** This package includes custom TypeScript type definitions for the `osc` library in `src/types/osc.d.ts` since the osc package doesn't provide its own types.
329
+ - roll in nodemon
330
+ - add some way to send messages on an interval