command-cmd 1.0.7 → 1.0.11

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 (4) hide show
  1. package/cmd.js +61 -0
  2. package/doc.md +30 -4
  3. package/docPTBR.md +22 -3
  4. package/package.json +1 -1
package/cmd.js CHANGED
@@ -587,6 +587,67 @@ export async function cursor(input, options = {}) {
587
587
  };
588
588
  }
589
589
 
590
+ export async function cursorSequential(input, intervalMs = 3000, options = {}) {
591
+ const commands = normalizeCursorInput(input);
592
+ const parsedInterval = toNonNegativeInteger(intervalMs);
593
+
594
+ if (parsedInterval === null) {
595
+ throw new Error('cursor_sequential_requires_non_negative_interval_ms');
596
+ }
597
+
598
+ if (commands.length === 0) {
599
+ return {
600
+ executed: [],
601
+ skipped: [{ reason: 'no_commands' }],
602
+ totalCommands: 0,
603
+ totalExecutions: 0,
604
+ intervalMs: parsedInterval
605
+ };
606
+ }
607
+
608
+ if (commands.length === 1) {
609
+ const singleResult = await cursor(commands[0], options);
610
+ return {
611
+ ...singleResult,
612
+ intervalMs: parsedInterval
613
+ };
614
+ }
615
+
616
+ const executed = [];
617
+ const skipped = [];
618
+
619
+ for (let commandIndex = 0; commandIndex < commands.length; commandIndex++) {
620
+ const command = commands[commandIndex];
621
+ const result = await cursor(command, options);
622
+
623
+ for (const entry of result.executed) {
624
+ executed.push({
625
+ ...entry,
626
+ commandIndex
627
+ });
628
+ }
629
+
630
+ for (const entry of result.skipped) {
631
+ skipped.push({
632
+ ...entry,
633
+ commandIndex
634
+ });
635
+ }
636
+
637
+ if (commandIndex < commands.length - 1 && parsedInterval > 0) {
638
+ await sleep(parsedInterval);
639
+ }
640
+ }
641
+
642
+ return {
643
+ executed,
644
+ skipped,
645
+ totalCommands: commands.length,
646
+ totalExecutions: executed.length,
647
+ intervalMs: parsedInterval
648
+ };
649
+ }
650
+
590
651
  function createCursorRuntime(options) {
591
652
  const config = buildCursorConfig(options);
592
653
  let mapStorePromise;
package/doc.md CHANGED
@@ -7,6 +7,7 @@ Exported functions:
7
7
  - `cmd`
8
8
  - `extractFirstCommand`
9
9
  - `cursor`
10
+ - `cursorSequential`
10
11
  - `initMap`
11
12
  - `initDoc`
12
13
  - `maper`
@@ -20,7 +21,15 @@ npm install command-cmd
20
21
  ## Import
21
22
 
22
23
  ```js
23
- import { cmd, extractFirstCommand, cursor, initMap, initDoc, maper } from 'command-cmd';
24
+ import {
25
+ cmd,
26
+ extractFirstCommand,
27
+ cursor,
28
+ cursorSequential,
29
+ initMap,
30
+ initDoc,
31
+ maper
32
+ } from 'command-cmd';
24
33
  ```
25
34
 
26
35
  ## 1) `cmd(message)`
@@ -111,7 +120,24 @@ Accepted object keys:
111
120
  - `seq` or `sequencia`
112
121
  - `extra`
113
122
 
114
- ## 4) `initMap(options?)`
123
+ ## 4) `cursorSequential(input, intervalMs = 3000, options?)`
124
+
125
+ Runs commands sequentially with a fixed delay between each command block.
126
+
127
+ - uses the same input format as `cursor`
128
+ - if input has 2+ commands, it executes them in written order
129
+ - default interval is `3000` ms (3 seconds)
130
+
131
+ Example:
132
+
133
+ ```js
134
+ await cursorSequential(
135
+ '[open_app, command: chrome][close_app, command: chrome]',
136
+ 3000
137
+ );
138
+ ```
139
+
140
+ ## 5) `initMap(options?)`
115
141
 
116
142
  Creates (or loads/merges) `map.json` explicitly.
117
143
 
@@ -132,7 +158,7 @@ Optional keys:
132
158
  - `skipAdsPoint`
133
159
  - `persistMerged` (writes merged defaults even when map already exists)
134
160
 
135
- ## 5) `initDoc(options?)`
161
+ ## 6) `initDoc(options?)`
136
162
 
137
163
  Creates documentation files from package templates.
138
164
 
@@ -157,7 +183,7 @@ Optional keys:
157
183
  - `includeMapDocs`
158
184
  - `files` (e.g. `['doc', 'docPTBR', 'map', 'mapPTBR']`)
159
185
 
160
- ## 6) `maper(enabled)`
186
+ ## 7) `maper(enabled)`
161
187
 
162
188
  Turns terminal mouse position mapping on/off.
163
189
 
package/docPTBR.md CHANGED
@@ -7,6 +7,7 @@ Funcoes exportadas:
7
7
  - `cmd`
8
8
  - `extractFirstCommand`
9
9
  - `cursor`
10
+ - `cursorSequential`
10
11
  - `initMap`
11
12
  - `initDoc`
12
13
  - `maper`
@@ -24,6 +25,7 @@ import {
24
25
  cmd as extrairComandos,
25
26
  extractFirstCommand as extrairPrimeiroComando,
26
27
  cursor as executarCursor,
28
+ cursorSequential as executarCursorSequencial,
27
29
  initMap as iniciarMap,
28
30
  initDoc as iniciarDoc,
29
31
  maper
@@ -118,7 +120,24 @@ Campos aceitos no objeto:
118
120
  - `seq` ou `sequencia`
119
121
  - `extra`
120
122
 
121
- ## 4) `initMap(options?)`
123
+ ## 4) `cursorSequential(input, intervalMs = 3000, options?)`
124
+
125
+ Executa comandos de forma sequencial com intervalo fixo entre cada bloco de comando.
126
+
127
+ - usa o mesmo formato de entrada do `cursor`
128
+ - se a string tiver 2+ comandos, executa na ordem em que foram escritos
129
+ - intervalo padrao de `3000` ms (3 segundos)
130
+
131
+ Exemplo:
132
+
133
+ ```js
134
+ await executarCursorSequencial(
135
+ '[abrir_app, comando: chrome][fechar_app, comando: chrome]',
136
+ 3000
137
+ );
138
+ ```
139
+
140
+ ## 5) `initMap(options?)`
122
141
 
123
142
  Cria (ou carrega/mescla) o `map.json` de forma explicita.
124
143
 
@@ -139,7 +158,7 @@ Campos opcionais:
139
158
  - `skipAdsPoint`
140
159
  - `persistMerged` (salva defaults mesclados mesmo se o map ja existir)
141
160
 
142
- ## 5) `initDoc(options?)`
161
+ ## 6) `initDoc(options?)`
143
162
 
144
163
  Cria os arquivos de documentacao usando os templates do pacote.
145
164
 
@@ -164,7 +183,7 @@ Campos opcionais:
164
183
  - `includeMapDocs`
165
184
  - `files` (ex.: `['doc', 'docPTBR', 'map', 'mapPTBR']`)
166
185
 
167
- ## 6) `maper(enabled)`
186
+ ## 7) `maper(enabled)`
168
187
 
169
188
  Liga/desliga o mapeador de posicao do mouse no terminal.
170
189
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "command-cmd",
3
- "version": "1.0.7",
3
+ "version": "1.0.11",
4
4
  "main": "cmd.js",
5
5
  "type": "module",
6
6
  "scripts": {