starlight-cli 1.0.16 → 1.0.17

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/dist/index.js CHANGED
@@ -2456,7 +2456,7 @@ const Lexer = __nccwpck_require__(211);
2456
2456
  const Parser = __nccwpck_require__(222);
2457
2457
  const Evaluator = __nccwpck_require__(112);
2458
2458
 
2459
- const VERSION = '1.0.16';
2459
+ const VERSION = '1.0.17';
2460
2460
 
2461
2461
  const COLOR = {
2462
2462
  reset: '\x1b[0m',
@@ -2470,7 +2470,6 @@ const COLOR = {
2470
2470
  magenta: '\x1b[35m'
2471
2471
  };
2472
2472
 
2473
-
2474
2473
  function waitAndExit(code = 0) {
2475
2474
  try { process.stdin.setRawMode(true); } catch {}
2476
2475
  console.error(COLOR.gray + '\nPress any key to exit...' + COLOR.reset);
@@ -2483,57 +2482,79 @@ function fatal(msg) {
2483
2482
  waitAndExit(1);
2484
2483
  }
2485
2484
 
2486
-
2487
2485
  function highlightCode(line) {
2488
2486
  return line
2489
- // strings
2490
2487
  .replace(/"(?:\\.|[^"])*"/g, m => COLOR.yellow + m + COLOR.reset)
2491
- // numbers
2492
2488
  .replace(/\b\d+(\.\d+)?\b/g, m => COLOR.magenta + m + COLOR.reset)
2493
- // keywords
2494
2489
  .replace(
2495
- /\b(sldeploy|import|from|const|let|var|if|else|for|while|func|return|break|continue|define|ask)\b/g,
2490
+ /\b(sldeploy|import|from|let|if|else|for|while|func|return|break|continue|define|ask)\b/g,
2496
2491
  m => COLOR.blue + m + COLOR.reset
2497
2492
  );
2498
2493
  }
2499
2494
 
2495
+ function openURL(url) {
2496
+ const platform = process.platform;
2497
+ let command;
2498
+
2499
+ if (platform === 'win32') command = `start "" "${url}"`;
2500
+ else if (platform === 'darwin') command = `open "${url}"`;
2501
+ else command = `xdg-open "${url}"`;
2502
+
2503
+ exec(command);
2504
+ }
2500
2505
 
2501
2506
  const args = process.argv.slice(2);
2502
2507
 
2503
2508
  if (args.length === 0) {
2504
2509
  console.log(`
2505
- Starlight Programming Language
2510
+ ${COLOR.bold}Starlight Programming Language${COLOR.reset}
2511
+ ${COLOR.magenta}Developed by Macedon${COLOR.reset}
2506
2512
 
2507
2513
  Usage:
2508
- starlight <file.sl>
2509
- starlight -v
2510
- starlight --help
2511
- starlight --learn
2512
- starlight --writedirectly
2514
+ starlight <file.sl> Run a Starlight file
2515
+ starlight -v Show version
2516
+ starlight --help Show help
2517
+ starlight --learn Open learning guide
2518
+ starlight --writedirectly Interactive editor
2513
2519
  `);
2514
2520
  process.exit(0);
2515
2521
  }
2516
2522
 
2517
2523
  if (args[0] === '-v' || args[0] === '--version') {
2518
- console.log(`Starlight CLI v${VERSION}`);
2524
+ console.log(`${COLOR.bold}Starlight CLI v${VERSION}${COLOR.reset}`);
2525
+ console.log(`${COLOR.magenta}Developed by Macedon${COLOR.reset}`);
2519
2526
  process.exit(0);
2520
2527
  }
2521
2528
 
2522
2529
  if (args[0] === '--help') {
2523
2530
  console.log(`
2524
- starlight <file.sl> Run file
2525
- starlight --writedirectly Interactive editor (Notepad and VS Code are recommended!)
2526
- starlight --learn Learning guide
2531
+ ${COLOR.bold}Starlight CLI v${VERSION}${COLOR.reset}
2532
+ ${COLOR.magenta}Developed by Macedon${COLOR.reset}
2533
+
2534
+ Commands:
2535
+ ${COLOR.green}starlight <file.sl>${COLOR.reset}
2536
+ Run a Starlight source file
2537
+
2538
+ ${COLOR.green}starlight -v${COLOR.reset}
2539
+ Show CLI version
2540
+
2541
+ ${COLOR.green}starlight --help${COLOR.reset}
2542
+ Show this help message
2543
+
2544
+ ${COLOR.green}starlight --learn${COLOR.reset}
2545
+ Open the official learning guide
2546
+
2547
+ ${COLOR.green}starlight --writedirectly${COLOR.reset}
2548
+ Interactive editor mode
2527
2549
  `);
2528
2550
  process.exit(0);
2529
2551
  }
2530
2552
 
2531
2553
  if (args[0] === '--learn') {
2532
- exec('start https://programming-lang.pages.dev/learning-guide');
2554
+ openURL('https://programming-lang.pages.dev/learning-guide');
2533
2555
  process.exit(0);
2534
2556
  }
2535
2557
 
2536
-
2537
2558
  if (args[0] === '--writedirectly') {
2538
2559
  const tempFile = path.join(os.tmpdir(), `starlight-${Date.now()}.sl`);
2539
2560
  const lines = [];
@@ -2566,7 +2587,6 @@ if (args[0] === '--writedirectly') {
2566
2587
  return;
2567
2588
  }
2568
2589
 
2569
-
2570
2590
  function savePrompt(lines) {
2571
2591
  try { process.stdin.setRawMode(false); } catch {}
2572
2592
 
@@ -2620,7 +2640,8 @@ function runFile(filePath, isTemp = false, callback) {
2620
2640
 
2621
2641
  if (!args[0].startsWith('--')) {
2622
2642
  runFile(path.resolve(args[0]));
2623
- }
2643
+ }
2644
+
2624
2645
  module.exports = __webpack_exports__;
2625
2646
  /******/ })()
2626
2647
  ;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starlight-cli",
3
- "version": "1.0.16",
3
+ "version": "1.0.17",
4
4
  "description": "Starlight Programming Language CLI",
5
5
  "bin": {
6
6
  "starlight": "index.js"
package/src/starlight.js CHANGED
@@ -9,7 +9,7 @@ const Lexer = require('./lexer');
9
9
  const Parser = require('./parser');
10
10
  const Evaluator = require('./evaluator');
11
11
 
12
- const VERSION = '1.0.16';
12
+ const VERSION = '1.0.17';
13
13
 
14
14
  const COLOR = {
15
15
  reset: '\x1b[0m',
@@ -23,7 +23,6 @@ const COLOR = {
23
23
  magenta: '\x1b[35m'
24
24
  };
25
25
 
26
-
27
26
  function waitAndExit(code = 0) {
28
27
  try { process.stdin.setRawMode(true); } catch {}
29
28
  console.error(COLOR.gray + '\nPress any key to exit...' + COLOR.reset);
@@ -36,57 +35,79 @@ function fatal(msg) {
36
35
  waitAndExit(1);
37
36
  }
38
37
 
39
-
40
38
  function highlightCode(line) {
41
39
  return line
42
- // strings
43
40
  .replace(/"(?:\\.|[^"])*"/g, m => COLOR.yellow + m + COLOR.reset)
44
- // numbers
45
41
  .replace(/\b\d+(\.\d+)?\b/g, m => COLOR.magenta + m + COLOR.reset)
46
- // keywords
47
42
  .replace(
48
- /\b(sldeploy|import|from|const|let|var|if|else|for|while|func|return|break|continue|define|ask)\b/g,
43
+ /\b(sldeploy|import|from|let|if|else|for|while|func|return|break|continue|define|ask)\b/g,
49
44
  m => COLOR.blue + m + COLOR.reset
50
45
  );
51
46
  }
52
47
 
48
+ function openURL(url) {
49
+ const platform = process.platform;
50
+ let command;
51
+
52
+ if (platform === 'win32') command = `start "" "${url}"`;
53
+ else if (platform === 'darwin') command = `open "${url}"`;
54
+ else command = `xdg-open "${url}"`;
55
+
56
+ exec(command);
57
+ }
53
58
 
54
59
  const args = process.argv.slice(2);
55
60
 
56
61
  if (args.length === 0) {
57
62
  console.log(`
58
- Starlight Programming Language
63
+ ${COLOR.bold}Starlight Programming Language${COLOR.reset}
64
+ ${COLOR.magenta}Developed by Macedon${COLOR.reset}
59
65
 
60
66
  Usage:
61
- starlight <file.sl>
62
- starlight -v
63
- starlight --help
64
- starlight --learn
65
- starlight --writedirectly
67
+ starlight <file.sl> Run a Starlight file
68
+ starlight -v Show version
69
+ starlight --help Show help
70
+ starlight --learn Open learning guide
71
+ starlight --writedirectly Interactive editor
66
72
  `);
67
73
  process.exit(0);
68
74
  }
69
75
 
70
76
  if (args[0] === '-v' || args[0] === '--version') {
71
- console.log(`Starlight CLI v${VERSION}`);
77
+ console.log(`${COLOR.bold}Starlight CLI v${VERSION}${COLOR.reset}`);
78
+ console.log(`${COLOR.magenta}Developed by Macedon${COLOR.reset}`);
72
79
  process.exit(0);
73
80
  }
74
81
 
75
82
  if (args[0] === '--help') {
76
83
  console.log(`
77
- starlight <file.sl> Run file
78
- starlight --writedirectly Interactive editor (Notepad and VS Code are recommended!)
79
- starlight --learn Learning guide
84
+ ${COLOR.bold}Starlight CLI v${VERSION}${COLOR.reset}
85
+ ${COLOR.magenta}Developed by Macedon${COLOR.reset}
86
+
87
+ Commands:
88
+ ${COLOR.green}starlight <file.sl>${COLOR.reset}
89
+ Run a Starlight source file
90
+
91
+ ${COLOR.green}starlight -v${COLOR.reset}
92
+ Show CLI version
93
+
94
+ ${COLOR.green}starlight --help${COLOR.reset}
95
+ Show this help message
96
+
97
+ ${COLOR.green}starlight --learn${COLOR.reset}
98
+ Open the official learning guide
99
+
100
+ ${COLOR.green}starlight --writedirectly${COLOR.reset}
101
+ Interactive editor mode
80
102
  `);
81
103
  process.exit(0);
82
104
  }
83
105
 
84
106
  if (args[0] === '--learn') {
85
- exec('start https://programming-lang.pages.dev/learning-guide');
107
+ openURL('https://programming-lang.pages.dev/learning-guide');
86
108
  process.exit(0);
87
109
  }
88
110
 
89
-
90
111
  if (args[0] === '--writedirectly') {
91
112
  const tempFile = path.join(os.tmpdir(), `starlight-${Date.now()}.sl`);
92
113
  const lines = [];
@@ -119,7 +140,6 @@ if (args[0] === '--writedirectly') {
119
140
  return;
120
141
  }
121
142
 
122
-
123
143
  function savePrompt(lines) {
124
144
  try { process.stdin.setRawMode(false); } catch {}
125
145
 
@@ -173,4 +193,4 @@ function runFile(filePath, isTemp = false, callback) {
173
193
 
174
194
  if (!args[0].startsWith('--')) {
175
195
  runFile(path.resolve(args[0]));
176
- }
196
+ }