roguelike-cli 1.2.4 → 1.2.6
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 +1 -1
- package/dist/interactive/commands.js +44 -18
- package/dist/interactive/startup.js +1 -1
- package/package.json +1 -1
- package/src/interactive/commands.ts +52 -19
- package/src/interactive/startup.ts +1 -1
package/README.md
CHANGED
|
@@ -330,16 +330,26 @@ async function processCommand(input, currentPath, config, signal, rl) {
|
|
|
330
330
|
}
|
|
331
331
|
return wrapResult({ output: treeLines.join('\n') });
|
|
332
332
|
}
|
|
333
|
-
// Handle navigation without 'cd' command (..,
|
|
334
|
-
if (command
|
|
335
|
-
|
|
333
|
+
// Handle navigation without 'cd' command (.., ..., ...., etc)
|
|
334
|
+
if (/^\.{2,}$/.test(command)) {
|
|
335
|
+
// Count dots: .. = 1 level, ... = 2 levels, .... = 3 levels, etc
|
|
336
|
+
const levels = command.length - 1;
|
|
336
337
|
let targetPath = currentPath;
|
|
338
|
+
// Already at root?
|
|
339
|
+
if (targetPath === config.storagePath) {
|
|
340
|
+
return { output: 'Already at root.' };
|
|
341
|
+
}
|
|
337
342
|
for (let i = 0; i < levels; i++) {
|
|
338
343
|
const parentPath = path.dirname(targetPath);
|
|
339
|
-
|
|
340
|
-
|
|
344
|
+
// Stop at storage root
|
|
345
|
+
if (targetPath === config.storagePath || parentPath.length < config.storagePath.length) {
|
|
346
|
+
break;
|
|
341
347
|
}
|
|
342
348
|
targetPath = parentPath;
|
|
349
|
+
// If we reached root, stop
|
|
350
|
+
if (targetPath === config.storagePath) {
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
343
353
|
}
|
|
344
354
|
return { newPath: targetPath, output: '' };
|
|
345
355
|
}
|
|
@@ -468,18 +478,25 @@ async function processCommand(input, currentPath, config, signal, rl) {
|
|
|
468
478
|
return { output: 'Usage: cd <node> or cd .. or cd <path>' };
|
|
469
479
|
}
|
|
470
480
|
const target = parts.slice(1).join(' ');
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
481
|
+
// Handle cd .., cd ..., cd ...., etc
|
|
482
|
+
if (/^\.{2,}$/.test(target)) {
|
|
483
|
+
const levels = target.length - 1;
|
|
484
|
+
let targetPath = currentPath;
|
|
485
|
+
// Already at root?
|
|
486
|
+
if (targetPath === config.storagePath) {
|
|
474
487
|
return { output: 'Already at root.' };
|
|
475
488
|
}
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
489
|
+
for (let i = 0; i < levels; i++) {
|
|
490
|
+
const parentPath = path.dirname(targetPath);
|
|
491
|
+
// Stop at storage root
|
|
492
|
+
if (targetPath === config.storagePath || parentPath.length < config.storagePath.length) {
|
|
493
|
+
break;
|
|
494
|
+
}
|
|
495
|
+
targetPath = parentPath;
|
|
496
|
+
// If we reached root, stop
|
|
497
|
+
if (targetPath === config.storagePath) {
|
|
498
|
+
break;
|
|
499
|
+
}
|
|
483
500
|
}
|
|
484
501
|
return { newPath: targetPath, output: '' };
|
|
485
502
|
}
|
|
@@ -488,13 +505,22 @@ async function processCommand(input, currentPath, config, signal, rl) {
|
|
|
488
505
|
let targetPath = currentPath;
|
|
489
506
|
const pathParts = target.split('/');
|
|
490
507
|
for (const part of pathParts) {
|
|
491
|
-
if (part
|
|
492
|
-
|
|
508
|
+
if (/^\.{2,}$/.test(part)) {
|
|
509
|
+
// Handle .., ..., ...., etc in path
|
|
510
|
+
const levels = part.length - 1;
|
|
511
|
+
for (let i = 0; i < levels; i++) {
|
|
512
|
+
if (targetPath === config.storagePath)
|
|
513
|
+
break;
|
|
514
|
+
const parentPath = path.dirname(targetPath);
|
|
515
|
+
if (parentPath.length < config.storagePath.length)
|
|
516
|
+
break;
|
|
517
|
+
targetPath = parentPath;
|
|
518
|
+
}
|
|
493
519
|
}
|
|
494
520
|
else if (part === '.') {
|
|
495
521
|
continue;
|
|
496
522
|
}
|
|
497
|
-
else {
|
|
523
|
+
else if (part) {
|
|
498
524
|
const newPath = (0, storage_1.navigateToNode)(targetPath, part);
|
|
499
525
|
if (!newPath) {
|
|
500
526
|
return { output: `Path "${target}" not found.` };
|
package/package.json
CHANGED
|
@@ -367,17 +367,31 @@ export async function processCommand(
|
|
|
367
367
|
return wrapResult({ output: treeLines.join('\n') });
|
|
368
368
|
}
|
|
369
369
|
|
|
370
|
-
// Handle navigation without 'cd' command (..,
|
|
371
|
-
if (command
|
|
372
|
-
|
|
370
|
+
// Handle navigation without 'cd' command (.., ..., ...., etc)
|
|
371
|
+
if (/^\.{2,}$/.test(command)) {
|
|
372
|
+
// Count dots: .. = 1 level, ... = 2 levels, .... = 3 levels, etc
|
|
373
|
+
const levels = command.length - 1;
|
|
373
374
|
let targetPath = currentPath;
|
|
374
375
|
|
|
376
|
+
// Already at root?
|
|
377
|
+
if (targetPath === config.storagePath) {
|
|
378
|
+
return { output: 'Already at root.' };
|
|
379
|
+
}
|
|
380
|
+
|
|
375
381
|
for (let i = 0; i < levels; i++) {
|
|
376
382
|
const parentPath = path.dirname(targetPath);
|
|
377
|
-
|
|
378
|
-
|
|
383
|
+
|
|
384
|
+
// Stop at storage root
|
|
385
|
+
if (targetPath === config.storagePath || parentPath.length < config.storagePath.length) {
|
|
386
|
+
break;
|
|
379
387
|
}
|
|
388
|
+
|
|
380
389
|
targetPath = parentPath;
|
|
390
|
+
|
|
391
|
+
// If we reached root, stop
|
|
392
|
+
if (targetPath === config.storagePath) {
|
|
393
|
+
break;
|
|
394
|
+
}
|
|
381
395
|
}
|
|
382
396
|
|
|
383
397
|
return { newPath: targetPath, output: '' };
|
|
@@ -531,20 +545,32 @@ export async function processCommand(
|
|
|
531
545
|
|
|
532
546
|
const target = parts.slice(1).join(' ');
|
|
533
547
|
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
548
|
+
// Handle cd .., cd ..., cd ...., etc
|
|
549
|
+
if (/^\.{2,}$/.test(target)) {
|
|
550
|
+
const levels = target.length - 1;
|
|
551
|
+
let targetPath = currentPath;
|
|
552
|
+
|
|
553
|
+
// Already at root?
|
|
554
|
+
if (targetPath === config.storagePath) {
|
|
537
555
|
return { output: 'Already at root.' };
|
|
538
556
|
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
557
|
+
|
|
558
|
+
for (let i = 0; i < levels; i++) {
|
|
559
|
+
const parentPath = path.dirname(targetPath);
|
|
560
|
+
|
|
561
|
+
// Stop at storage root
|
|
562
|
+
if (targetPath === config.storagePath || parentPath.length < config.storagePath.length) {
|
|
563
|
+
break;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
targetPath = parentPath;
|
|
567
|
+
|
|
568
|
+
// If we reached root, stop
|
|
569
|
+
if (targetPath === config.storagePath) {
|
|
570
|
+
break;
|
|
571
|
+
}
|
|
547
572
|
}
|
|
573
|
+
|
|
548
574
|
return { newPath: targetPath, output: '' };
|
|
549
575
|
}
|
|
550
576
|
|
|
@@ -554,11 +580,18 @@ export async function processCommand(
|
|
|
554
580
|
const pathParts = target.split('/');
|
|
555
581
|
|
|
556
582
|
for (const part of pathParts) {
|
|
557
|
-
if (part
|
|
558
|
-
|
|
583
|
+
if (/^\.{2,}$/.test(part)) {
|
|
584
|
+
// Handle .., ..., ...., etc in path
|
|
585
|
+
const levels = part.length - 1;
|
|
586
|
+
for (let i = 0; i < levels; i++) {
|
|
587
|
+
if (targetPath === config.storagePath) break;
|
|
588
|
+
const parentPath = path.dirname(targetPath);
|
|
589
|
+
if (parentPath.length < config.storagePath.length) break;
|
|
590
|
+
targetPath = parentPath;
|
|
591
|
+
}
|
|
559
592
|
} else if (part === '.') {
|
|
560
593
|
continue;
|
|
561
|
-
} else {
|
|
594
|
+
} else if (part) {
|
|
562
595
|
const newPath = navigateToNode(targetPath, part);
|
|
563
596
|
if (!newPath) {
|
|
564
597
|
return { output: `Path "${target}" not found.` };
|