janofidel 1.0.0 → 1.0.1

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/package.json +1 -1
  2. package/src/runner.js +29 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "janofidel",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Amharic Programming Language (Jano Fidel)",
5
5
  "main": "src/engine.js",
6
6
  "bin": {
package/src/runner.js CHANGED
@@ -1,9 +1,9 @@
1
1
  const { spawn } = require('child_process');
2
2
  const fs = require('fs');
3
3
  const path = require('path');
4
- const hookPath = require.resolve('./hook');
4
+ const { version } = require('../package.json'); // Pull version from package.json
5
5
 
6
- // --- 1. Helpers (Top of the file) ---
6
+ // --- 1. Helpers ---
7
7
 
8
8
  const style = {
9
9
  red: (t) => `\x1b[31m${t}\x1b[0m`,
@@ -12,6 +12,30 @@ const style = {
12
12
  reset: '\x1b[0m'
13
13
  };
14
14
 
15
+ /**
16
+ * Handles CLI flags before running code
17
+ * @param {string[]} args
18
+ */
19
+ function handleFlags(args) {
20
+ if (args.includes('--version') || args.includes('-v')) {
21
+ console.log(`ጃኖ ፊደል (Jano Fidel) - Version ${version}`);
22
+ process.exit(0);
23
+ }
24
+ if (args.includes('--help') || args.includes('-h')) {
25
+ console.log(`
26
+ ${style.bold("ጃኖ ፊደል (Jano Fidel) CLI")}
27
+
28
+ ${style.bold("አጠቃቀም (Usage):")}
29
+ jano <ፋይል_ስም.jf>
30
+
31
+ ${style.bold("ትዕዛዞች (Flags):")}
32
+ -v, --version የስሪት ቁጥሩን ያሳያል (Show version)
33
+ -h, --help ይህንን መመሪያ ያሳያል (Show help)
34
+ `);
35
+ process.exit(0);
36
+ }
37
+ }
38
+
15
39
  function getExitSummary(code) {
16
40
  if (code === 1) return "ያልተጠበቀ ስህተት አጋጥሟል (Uncaught Error)";
17
41
  if (code === 130) return "ተጠቃሚው ፕሮግራሙን አቋርጦታል (User Interrupted)";
@@ -28,6 +52,9 @@ function remapStack(data, tempFilePath, originalFileName) {
28
52
  // --- 2. Main Execution Function ---
29
53
 
30
54
  function runCode(jsCode, originalFilePath) {
55
+ // Check flags from the actual command line
56
+ handleFlags(process.argv.slice(2));
57
+
31
58
  const fileName = path.basename(originalFilePath);
32
59
  const dirName = path.dirname(path.resolve(originalFilePath));
33
60
  const tempFile = path.join(dirName, `.${path.basename(originalFilePath, '.jf')}.tmp.js`);
@@ -35,7 +62,6 @@ function runCode(jsCode, originalFilePath) {
35
62
  try {
36
63
  fs.writeFileSync(tempFile, jsCode, 'utf8');
37
64
 
38
- // Preload the hook to handle imports
39
65
  const hookPath = require.resolve('./hook');
40
66
  const child = spawn('node', ['-r', hookPath, tempFile], {
41
67
  stdio: ['inherit', 'inherit', 'pipe'],
@@ -47,7 +73,6 @@ function runCode(jsCode, originalFilePath) {
47
73
  process.stderr.write(remappedError);
48
74
  });
49
75
 
50
- // --- THE BOX UI LOGIC HERE ---
51
76
  child.on('close', (code) => {
52
77
  if (fs.existsSync(tempFile)) {
53
78
  try { fs.unlinkSync(tempFile); } catch(e) {}