satoridb 1.1.24 → 1.1.25

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 (2) hide show
  1. package/cli.js +51 -9
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  let path = require("path");
4
4
  let os = require("os");
@@ -12,6 +12,46 @@ let binPath = path.join(os.homedir(), ".satori", "bin", binName);
12
12
 
13
13
  let satoriInstance = null;
14
14
 
15
+ // Function to parse arguments with quoted strings support
16
+ function parseArguments(line) {
17
+ let args = [];
18
+ let current = '';
19
+ let inQuotes = false;
20
+ let quoteChar = '';
21
+
22
+ for (let i = 0; i < line.length; i++) {
23
+ let char = line[i];
24
+
25
+ if ((char === '"' || char === "'") && !inQuotes) {
26
+ inQuotes = true;
27
+ quoteChar = char;
28
+ continue;
29
+ }
30
+
31
+ if (char === quoteChar && inQuotes) {
32
+ inQuotes = false;
33
+ quoteChar = '';
34
+ continue;
35
+ }
36
+
37
+ if (char === ' ' && !inQuotes) {
38
+ if (current.trim()) {
39
+ args.push(current.trim());
40
+ current = '';
41
+ }
42
+ continue;
43
+ }
44
+
45
+ current += char;
46
+ }
47
+
48
+ if (current.trim()) {
49
+ args.push(current.trim());
50
+ }
51
+
52
+ return args;
53
+ }
54
+
15
55
  // Función helper para parsear JSON, arrays y tipos básicos
16
56
  function parseData(data) {
17
57
  if (typeof data === 'string') {
@@ -156,7 +196,7 @@ async function executeCommand(command, args) {
156
196
 
157
197
  case "ask":
158
198
  if (args.length < 1) {
159
- console.log("❌ Uso: ask <question> [backend]");
199
+ console.log("❌ Usage: ask \"<question>\" [backend]");
160
200
  return;
161
201
  }
162
202
  let question = args[0];
@@ -167,7 +207,7 @@ async function executeCommand(command, args) {
167
207
 
168
208
  case "query":
169
209
  if (args.length < 1) {
170
- console.log("❌ Uso: query <query> [backend]");
210
+ console.log("❌ Usage: query \"<query>\" [backend]");
171
211
  return;
172
212
  }
173
213
  let query = args[0];
@@ -323,15 +363,18 @@ function showHelp() {
323
363
  put <key> <field> <value> - Update a specific field
324
364
  get <key> - Get data from a key
325
365
  delete <key> - Delete a key
326
- ask <question> [backend] - Ask a question
327
- query <query> [backend] - Make a query
366
+ ask "<question>" [backend] - Ask a question
367
+ query "<query>" [backend] - Make a query
328
368
 
329
369
  🛠️ Others:
330
370
  help - Show this help
331
371
  exit / quit - Exit the CLI
332
372
  clear - Clear screen
333
373
 
334
- 💡 Example: set user:123 '{"name": "John", "age": 25}'
374
+ 💡 Examples:
375
+ set user:123 '{"name": "John", "age": 25}'
376
+ ask "What is the weather like today?"
377
+ query "Find all users with age > 25"
335
378
  `);
336
379
  }
337
380
 
@@ -360,9 +403,8 @@ async function startInteractiveCLI() {
360
403
  return;
361
404
  }
362
405
 
363
-
364
-
365
- let parts = trimmedLine.split(' ');
406
+ // Parse arguments with quoted strings support
407
+ let parts = parseArguments(trimmedLine);
366
408
  let command = parts[0];
367
409
  let args = parts.slice(1);
368
410
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "satoridb",
3
- "version": "1.1.24",
3
+ "version": "1.1.25",
4
4
  "description": "Install satori",
5
5
  "bin": {
6
6
  "satoridb": "./cli.js"