producs 3.0.0 → 3.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 (4) hide show
  1. package/README.pd +1 -0
  2. package/cli.js +17 -0
  3. package/index.js +8 -0
  4. package/package.json +3 -3
package/README.pd CHANGED
@@ -197,6 +197,7 @@
197
197
  #$Table
198
198
  #$Row['Command','Description']
199
199
  #$Row['Set[name,value]','Set a variable']
200
+ #$Row['Get[name]', 'Get the value of a variable']
200
201
  #$Row['Unset[name]','Delete a variable']
201
202
  #$Row['Export[name,value]','Set variable and push to process.env']
202
203
  #$Row['Env_get[KEY]','Read process.env.KEY into VALUE']
package/cli.js CHANGED
@@ -30,6 +30,7 @@ ${bold("Flags:")}
30
30
  ${bold("--no-color")} Disable ANSI colors
31
31
  ${bold("--ast")} Dump AST as JSON and exit (no execution)
32
32
  ${bold("--demo")} Run the built-in feature demo
33
+ ${bold("--readme")} Run the built-in interactive readme (built in producs itself, not in markdown)
33
34
  ${bold("--help")} Show this message
34
35
  ${bold("--version")} Print version
35
36
 
@@ -65,6 +66,11 @@ ${dim("─".repeat(60))}
65
66
  const DEMO = require("fs").readFileSync(
66
67
  require("path").join(__dirname, "examples", "demo.pd"), "utf8"
67
68
  );
69
+
70
+ const README = require("fs").readFileSync(
71
+ require("path").join(__dirname, "README.pd"), "utf8"
72
+ );
73
+
68
74
  // ─── Parse argv ───────────────────────────────────────────────────────────────
69
75
  const argv = process.argv.slice(2);
70
76
  const flags = new Set(argv.filter(a => a.startsWith("--")));
@@ -92,6 +98,17 @@ if (flags.has("--demo")) {
92
98
  process.exit(0);
93
99
  }
94
100
 
101
+ // ─── Readme ─────────────────────────────────────────────────────────────────────
102
+ if (flags.has("--readme")) {
103
+ try { prod.run(README); }
104
+ catch (e) {
105
+ process.stderr.write(red(`\n${e.name||"Error"}: ${e.message}\n`));
106
+ if (opts.debug && e.stack) process.stderr.write(dim(e.stack)+"\n");
107
+ process.exit(1);
108
+ }
109
+ process.exit(0);
110
+ }
111
+
95
112
  // ─── File execution ───────────────────────────────────────────────────────────
96
113
  const filePath = path.resolve(files[0]);
97
114
  let src;
package/index.js CHANGED
@@ -394,6 +394,14 @@ class CommandRegistry {
394
394
  return okResult(value);
395
395
  }, { doc:"Set['name','value'] or pipe VALUE into variable" });
396
396
 
397
+ R.register("Get", (node, input) => {
398
+ const [name=""] = rA(node.args);
399
+ const val = env.vars[name];
400
+ if (val === undefined) return failResult("",{reason:`variable ${name} not set`});
401
+ return okResult(val);
402
+ }, { doc:"Get['name'] → VALUE" });
403
+
404
+
397
405
  R.register("Unset", (node,input) => {
398
406
  const [name=""] = rA(node.args);
399
407
  delete env.vars[name]; return okResult(input.VALUE);
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "producs",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "Professional Documentation Shell DSL — a modular, pipeable terminal scripting language",
5
5
  "main": "index.js",
6
6
  "bin": {
7
- "producs": "./cli.js"
7
+ "producs": "cli.js"
8
8
  },
9
9
  "scripts": {
10
10
  "start": "node cli.js",
@@ -21,7 +21,7 @@
21
21
  "scripting",
22
22
  "pipeline"
23
23
  ],
24
- "author": "Purcwix",
24
+ "author": "purcwix",
25
25
  "license": "MIT",
26
26
  "dependencies": {
27
27
  "prompt-sync": "^4.2.0"