@rip-lang/script 0.1.1 → 0.1.2

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.
Files changed (3) hide show
  1. package/README.md +41 -41
  2. package/package.json +2 -2
  3. package/script.rip +2 -2
package/README.md CHANGED
@@ -59,9 +59,9 @@ You pass it an array. It processes each element by type:
59
59
  Spawn a local process with a real pseudo-terminal:
60
60
 
61
61
  ```coffee
62
- chat = Script.spawn! 'mumps -dir' # MUMPS console
63
- chat = Script.spawn! 'bash' # local shell
64
- chat = Script.spawn! 'python3', ['-i'] # interactive Python
62
+ chat = Script.spawn! 'mumps -dir' # MUMPS console
63
+ chat = Script.spawn! 'bash' # local shell
64
+ chat = Script.spawn! 'python3', ['-i'] # interactive Python
65
65
  ```
66
66
 
67
67
  ### SSH (Remote Systems)
@@ -71,7 +71,7 @@ Connect via SSH, using your `~/.ssh/config`, keys, and agent:
71
71
  ```coffee
72
72
  chat = Script.ssh! 'admin@company.example.com'
73
73
  chat = Script.ssh! 'ssh://user:pass@10.0.1.50:22'
74
- chat = Script.ssh! 'user@host', slow: 30 # longer timeout for slow links
74
+ chat = Script.ssh! 'user@host', slow: 30 # longer timeout for slow links
75
75
  ```
76
76
 
77
77
  ### TCP (Raw Socket)
@@ -117,9 +117,9 @@ The simplest pattern — strings alternate between waiting and sending:
117
117
 
118
118
  ```coffee
119
119
  chat! [
120
- ">", "D ^XUP" # wait for ">", send "D ^XUP"
121
- "Select OPTION:", "DG ADMIT PATIENT" # wait for prompt, send menu choice
122
- "Admit PATIENT:", "SMITH,JOHN" # wait for prompt, send patient name
120
+ ">", "D ^XUP" # wait for ">", send "D ^XUP"
121
+ "Select OPTION:", "DG ADMIT PATIENT" # wait for prompt, send menu choice
122
+ "Admit PATIENT:", "SMITH,JOHN" # wait for prompt, send patient name
123
123
  ]
124
124
  ```
125
125
 
@@ -144,9 +144,9 @@ Objects try each key against the output buffer — first match wins:
144
144
  chat! [
145
145
  "Enter name:", "SMITH,JOHN"
146
146
  {
147
- "SURE YOU WANT TO ADD": ["Y"] # if confirmation, say yes
148
- "Select ADMISSION DATE:": [""] # if date prompt, press enter
149
- "Do you want to continue": ["C"] # if continue prompt, continue
147
+ "SURE YOU WANT TO ADD": ["Y"] # if confirmation, say yes
148
+ "Select ADMISSION DATE:": [""] # if date prompt, press enter
149
+ "Do you want to continue": ["C"] # if continue prompt, continue
150
150
  }
151
151
  ]
152
152
  ```
@@ -161,9 +161,9 @@ import { mux, ELSE } from '@rip-lang/script'
161
161
  chat! [
162
162
  "Enter name:", "SMITH,JOHN"
163
163
  mux(
164
- /^NAME:/, [""] # regex key
165
- "CHOOSE 1", [1] # string key
166
- ELSE, null # fallback — nothing matched
164
+ /^NAME:/, [""] # regex key
165
+ "CHOOSE 1", [1] # string key
166
+ ELSE, null # fallback — nothing matched
167
167
  )
168
168
  ]
169
169
  ```
@@ -175,7 +175,7 @@ Arrays with a boolean first element execute conditionally:
175
175
  ```coffee
176
176
  chat! [
177
177
  "DIVISION:", data.division
178
- [data.hasBeds # only if hasBeds is true
178
+ [data.hasBeds # only if hasBeds is true
179
179
  "NUMBER OF BEDS:", data.beds
180
180
  "SERIOUSLY ILL:", "N"
181
181
  ]
@@ -190,7 +190,7 @@ Arrays without a boolean first element are nested sub-scripts:
190
190
  ```coffee
191
191
  chat! [
192
192
  "Select OPTION:", "EDIT"
193
- [ # nested conversation
193
+ [ # nested conversation
194
194
  "FIELD:", "NAME"
195
195
  "FIELD:", "TITLE"
196
196
  "FIELD:", ""
@@ -211,7 +211,7 @@ chat! [
211
211
  "Select KEY:", key
212
212
  { "KEY:": [""], "REVIEW DATE:": "" }
213
213
  ]
214
- true # continue to next item
214
+ true # continue to next item
215
215
 
216
216
  "Select KEY:", ""
217
217
  ]
@@ -237,7 +237,7 @@ pair = chat! [
237
237
  /\n([^\n]+)\n/
238
238
  ]
239
239
 
240
- systemInfo = pair[1] # the captured group
240
+ systemInfo = pair[1] # the captured group
241
241
  ```
242
242
 
243
243
  ### Control Flow
@@ -317,39 +317,39 @@ All connection factories accept options:
317
317
 
318
318
  ```coffee
319
319
  chat = Script.ssh! 'user@host',
320
- live: true # print received data to stdout (default: true)
321
- echo: false # print sent data to stdout (default: false)
322
- show: false # print matched data to stdout (default: false)
323
- slow: 10 # timeout in seconds waiting for output (default: 10)
324
- fast: 0.25 # timeout in seconds for "is there more?" (default: 0.25)
325
- bomb: true # throw on timeout (default: true)
326
- line: "\r" # line terminator appended to sends (default: "\r")
327
- ansi: false # keep ANSI escapes (default: false = strip them)
328
- nocr: true # strip \r characters (default: true)
329
- wait: null # [min, max] random delay in seconds before sends
330
- auth: [...] # initial authentication script to run on connect
331
- init: [...] # initialization script to run after auth
332
- onSend: null # (text) -> hook called after each send
333
- onRecv: null # (data) -> hook called after each read
334
- onMatch: null # (pattern, matched) -> hook called after each match
320
+ live: true # print received data to stdout (default: true)
321
+ echo: false # print sent data to stdout (default: false)
322
+ show: false # print matched data to stdout (default: false)
323
+ slow: 10 # timeout in seconds waiting for output (default: 10)
324
+ fast: 0.25 # timeout in seconds for "is there more?" (default: 0.25)
325
+ bomb: true # throw on timeout (default: true)
326
+ line: "\r" # line terminator appended to sends (default: "\r")
327
+ ansi: false # keep ANSI escapes (default: false = strip them)
328
+ nocr: true # strip \r characters (default: true)
329
+ wait: null # [min, max] random delay in seconds before sends
330
+ auth: [...] # initial authentication script to run on connect
331
+ init: [...] # initialization script to run after auth
332
+ onSend: null # (text) -> hook called after each send
333
+ onRecv: null # (data) -> hook called after each read
334
+ onMatch: null # (pattern, matched) -> hook called after each match
335
335
  ```
336
336
 
337
337
  ## Options Reference
338
338
 
339
339
  | Option | Default | Description |
340
340
  |--------|---------|-------------|
341
- | `live` | `true` | Print received data to stdout in real time |
341
+ | `live` | `true` | Print received data to stdout in real time |
342
342
  | `echo` | `false` | Print sent data to stdout |
343
343
  | `show` | `false` | Print matched/consumed text to stdout |
344
- | `slow` | `10` | Seconds to wait before timeout |
345
- | `fast` | `0.25` | Seconds for "is there more data?" check |
346
- | `bomb` | `true` | Throw on timeout (false = return silently) |
347
- | `line` | `"\r"` | Line terminator appended to every send |
344
+ | `slow` | `10` | Seconds to wait before timeout |
345
+ | `fast` | `0.25` | Seconds for "is there more data?" check |
346
+ | `bomb` | `true` | Throw on timeout (false = return silently) |
347
+ | `line` | `"\r"` | Line terminator appended to every send |
348
348
  | `ansi` | `false` | Keep ANSI escape sequences (false = strip) |
349
- | `nocr` | `true` | Strip carriage returns from received data |
350
- | `wait` | `null` | `[min, max]` random delay before sends (seconds) |
351
- | `auth` | `null` | Script array to run on connect (authentication) |
352
- | `init` | `null` | Script array to run after auth (initialization) |
349
+ | `nocr` | `true` | Strip carriage returns from received data |
350
+ | `wait` | `null` | `[min, max]` random delay before sends (seconds) |
351
+ | `auth` | `null` | Script array to run on connect (authentication) |
352
+ | `init` | `null` | Script array to run after auth (initialization) |
353
353
 
354
354
  ## Type Dispatch Reference
355
355
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rip-lang/script",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Homoiconic interaction engine — automate stateful conversations with remote systems using nested data structures",
5
5
  "type": "module",
6
6
  "main": "script.rip",
@@ -29,7 +29,7 @@
29
29
  "author": "Steve Shreeve <steve.shreeve@gmail.com>",
30
30
  "license": "MIT",
31
31
  "dependencies": {
32
- "rip-lang": ">=3.13.126"
32
+ "rip-lang": ">=3.13.127"
33
33
  },
34
34
  "files": [
35
35
  "script.rip",
package/script.rip CHANGED
@@ -158,10 +158,10 @@ class Engine
158
158
  return 'fast' if fast
159
159
  raise "Timeout waiting for data\nBuffer: #{JSON.stringify(@buff)}" if @bomb
160
160
  return 'slow'
161
- data .= replace /\r/g, '' if @nocr
162
- data = stripAnsi(data) unless @ansi
163
161
  process.stdout.write(data) if @live
164
162
  @opts.onRecv?(data)
163
+ data .= replace /\r/g, '' if @nocr
164
+ data = stripAnsi(data) unless @ansi
165
165
  @buff += data
166
166
 
167
167
  # -- Send text with line terminator --