aboutsummaryrefslogtreecommitdiff
path: root/docs/bqn.js
diff options
context:
space:
mode:
Diffstat (limited to 'docs/bqn.js')
-rwxr-xr-x[-rw-r--r--]docs/bqn.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/docs/bqn.js b/docs/bqn.js
index 406c20f8..c3c2d1ba 100644..100755
--- a/docs/bqn.js
+++ b/docs/bqn.js
@@ -1,3 +1,5 @@
+#! /usr/bin/env node
+
"use strict";
// Virtual machine
let has = x => x!==undefined;
@@ -286,4 +288,14 @@ let fmtErr = (s,e) => {
if (typeof module!=='undefined') {
bqn.fmt=fmt; bqn.fmtErr=fmtErr; bqn.compile=compile; bqn.run=run;
module.exports=bqn;
+ if (!module.parent) {
+ let args = process.argv.slice(2);
+ args.map(a=>{
+ try {
+ console.log(fmt(bqn(a)))
+ } catch(e) {
+ console.error(''+fmtErr(Array.from(a),e)+'');
+ }
+ });
+ }
}