novac 2.0.1 → 2.2.0
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/LICENSE +1 -1
- package/README.md +1574 -597
- package/bin/novac +468 -171
- package/bin/nvc +522 -0
- package/bin/nvml +78 -17
- package/demo.nv +0 -0
- package/demo_builtins.nv +0 -0
- package/demo_http.nv +0 -0
- package/examples/bf.nv +69 -0
- package/examples/math.nv +21 -0
- package/kits/birdAPI/kitdef.js +954 -0
- package/kits/kitRNG/kitdef.js +740 -0
- package/kits/kitSSH/kitdef.js +1272 -0
- package/kits/kitadb/kitdef.js +606 -0
- package/kits/kitai/kitdef.js +2185 -0
- package/kits/kitansi/kitdef.js +1402 -0
- package/kits/kitcanvas/kitdef.js +914 -0
- package/kits/kitclippy/kitdef.js +925 -0
- package/kits/kitformat/kitdef.js +1485 -0
- package/kits/kitgps/kitdef.js +1862 -0
- package/kits/kitlibproc/kitdef.js +3 -2
- package/kits/kitmatrix/ex.js +19 -0
- package/kits/kitmatrix/kitdef.js +960 -0
- package/kits/kitmorse/kitdef.js +229 -0
- package/kits/kitmpatch/kitdef.js +906 -0
- package/kits/kitnet/kitdef.js +1401 -0
- package/kits/kitnovacweb/README.md +1416 -143
- package/kits/kitnovacweb/kitdef.js +92 -2
- package/kits/kitnovacweb/nvml/executor.js +578 -176
- package/kits/kitnovacweb/nvml/index.js +2 -2
- package/kits/kitnovacweb/nvml/lexer.js +72 -69
- package/kits/kitnovacweb/nvml/parser.js +328 -159
- package/kits/kitnovacweb/nvml/renderer.js +770 -270
- package/kits/kitparse/kitdef.js +1688 -0
- package/kits/kitproto/kitdef.js +613 -0
- package/kits/kitqr/kitdef.js +637 -0
- package/kits/kitregex++/kitdef.js +1353 -0
- package/kits/kitrequire/kitdef.js +1599 -0
- package/kits/kitx11/kitdef.js +1 -0
- package/kits/kitx11/kitx11.js +2472 -0
- package/kits/kitx11/kitx11_conn.js +948 -0
- package/kits/kitx11/kitx11_worker.js +121 -0
- package/kits/libtea/kitdef.js +2691 -0
- package/kits/libterm/ex.js +285 -0
- package/kits/libterm/kitdef.js +1927 -0
- package/novac/LICENSE +21 -0
- package/novac/README.md +1823 -0
- package/novac/bin/novac +950 -0
- package/novac/bin/nvc +522 -0
- package/novac/bin/nvml +542 -0
- package/novac/demo.nv +245 -0
- package/novac/demo_builtins.nv +209 -0
- package/novac/demo_http.nv +62 -0
- package/novac/examples/bf.nv +69 -0
- package/novac/examples/math.nv +21 -0
- package/novac/kits/kitai/kitdef.js +2185 -0
- package/novac/kits/kitansi/kitdef.js +1402 -0
- package/novac/kits/kitformat/kitdef.js +1485 -0
- package/novac/kits/kitgps/kitdef.js +1862 -0
- package/novac/kits/kitlibfs/kitdef.js +231 -0
- package/{examples/example-project/nova_modules → novac/kits}/kitlibproc/kitdef.js +3 -2
- package/novac/kits/kitmatrix/ex.js +19 -0
- package/novac/kits/kitmatrix/kitdef.js +960 -0
- package/novac/kits/kitmpatch/kitdef.js +906 -0
- package/novac/kits/kitnovacweb/README.md +1572 -0
- package/novac/kits/kitnovacweb/demo.nv +12 -0
- package/novac/kits/kitnovacweb/demo.nvml +71 -0
- package/novac/kits/kitnovacweb/index.nova +12 -0
- package/novac/kits/kitnovacweb/kitdef.js +692 -0
- package/novac/kits/kitnovacweb/nova.kit.json +8 -0
- package/novac/kits/kitnovacweb/nvml/executor.js +739 -0
- package/novac/kits/kitnovacweb/nvml/index.js +67 -0
- package/novac/kits/kitnovacweb/nvml/lexer.js +263 -0
- package/novac/kits/kitnovacweb/nvml/parser.js +508 -0
- package/novac/kits/kitnovacweb/nvml/renderer.js +924 -0
- package/novac/kits/kitparse/kitdef.js +1688 -0
- package/novac/kits/kitregex++/kitdef.js +1353 -0
- package/novac/kits/kitrequire/kitdef.js +1599 -0
- package/novac/kits/kitx11/kitdef.js +1 -0
- package/novac/kits/kitx11/kitx11.js +2472 -0
- package/novac/kits/kitx11/kitx11_conn.js +948 -0
- package/novac/kits/kitx11/kitx11_worker.js +121 -0
- package/novac/kits/libtea/tf.js +2691 -0
- package/novac/kits/libterm/ex.js +285 -0
- package/novac/kits/libterm/kitdef.js +1927 -0
- package/novac/node_modules/chalk/license +9 -0
- package/novac/node_modules/chalk/package.json +83 -0
- package/novac/node_modules/chalk/readme.md +297 -0
- package/novac/node_modules/chalk/source/index.d.ts +325 -0
- package/novac/node_modules/chalk/source/index.js +225 -0
- package/novac/node_modules/chalk/source/utilities.js +33 -0
- package/novac/node_modules/chalk/source/vendor/ansi-styles/index.d.ts +236 -0
- package/novac/node_modules/chalk/source/vendor/ansi-styles/index.js +223 -0
- package/novac/node_modules/chalk/source/vendor/supports-color/browser.d.ts +1 -0
- package/novac/node_modules/chalk/source/vendor/supports-color/browser.js +34 -0
- package/novac/node_modules/chalk/source/vendor/supports-color/index.d.ts +55 -0
- package/novac/node_modules/chalk/source/vendor/supports-color/index.js +190 -0
- package/novac/node_modules/commander/LICENSE +22 -0
- package/novac/node_modules/commander/Readme.md +1176 -0
- package/novac/node_modules/commander/esm.mjs +16 -0
- package/novac/node_modules/commander/index.js +24 -0
- package/novac/node_modules/commander/lib/argument.js +150 -0
- package/novac/node_modules/commander/lib/command.js +2777 -0
- package/novac/node_modules/commander/lib/error.js +39 -0
- package/novac/node_modules/commander/lib/help.js +747 -0
- package/novac/node_modules/commander/lib/option.js +380 -0
- package/novac/node_modules/commander/lib/suggestSimilar.js +101 -0
- package/novac/node_modules/commander/package-support.json +19 -0
- package/novac/node_modules/commander/package.json +82 -0
- package/novac/node_modules/commander/typings/esm.d.mts +3 -0
- package/novac/node_modules/commander/typings/index.d.ts +1113 -0
- package/novac/node_modules/node-addon-api/LICENSE.md +9 -0
- package/novac/node_modules/node-addon-api/README.md +95 -0
- package/novac/node_modules/node-addon-api/common.gypi +21 -0
- package/novac/node_modules/node-addon-api/except.gypi +25 -0
- package/novac/node_modules/node-addon-api/index.js +14 -0
- package/novac/node_modules/node-addon-api/napi-inl.deprecated.h +186 -0
- package/novac/node_modules/node-addon-api/napi-inl.h +7165 -0
- package/novac/node_modules/node-addon-api/napi.h +3364 -0
- package/novac/node_modules/node-addon-api/node_addon_api.gyp +42 -0
- package/novac/node_modules/node-addon-api/node_api.gyp +9 -0
- package/novac/node_modules/node-addon-api/noexcept.gypi +26 -0
- package/novac/node_modules/node-addon-api/package-support.json +21 -0
- package/novac/node_modules/node-addon-api/package.json +480 -0
- package/novac/node_modules/node-addon-api/tools/README.md +73 -0
- package/novac/node_modules/node-addon-api/tools/check-napi.js +99 -0
- package/novac/node_modules/node-addon-api/tools/clang-format.js +71 -0
- package/novac/node_modules/node-addon-api/tools/conversion.js +301 -0
- package/novac/node_modules/serialize-javascript/LICENSE +27 -0
- package/novac/node_modules/serialize-javascript/README.md +149 -0
- package/novac/node_modules/serialize-javascript/index.js +297 -0
- package/novac/node_modules/serialize-javascript/package.json +33 -0
- package/novac/package.json +27 -0
- package/novac/scripts/update-bin.js +24 -0
- package/novac/src/core/bstd.js +1035 -0
- package/novac/src/core/config.js +155 -0
- package/novac/src/core/describe.js +187 -0
- package/novac/src/core/emitter.js +499 -0
- package/novac/src/core/error.js +86 -0
- package/novac/src/core/executor.js +5606 -0
- package/novac/src/core/formatter.js +686 -0
- package/novac/src/core/lexer.js +1026 -0
- package/novac/src/core/nova_builtins.js +717 -0
- package/novac/src/core/nova_thread_worker.js +166 -0
- package/novac/src/core/parser.js +2181 -0
- package/novac/src/core/types.js +112 -0
- package/novac/src/index.js +28 -0
- package/novac/src/runtime/stdlib.js +244 -0
- package/package.json +6 -3
- package/scripts/update-bin.js +0 -0
- package/src/core/bstd.js +838 -362
- package/src/core/executor.js +2578 -170
- package/src/core/lexer.js +502 -54
- package/src/core/nova_builtins.js +21 -3
- package/src/core/parser.js +413 -72
- package/src/core/types.js +30 -2
- package/src/index.js +0 -0
- package/examples/example-project/README.md +0 -3
- package/examples/example-project/src/main.nova +0 -3
- package/src/core/environment.js +0 -0
- /package/{examples/example-project/bin/example-project.nv → novac/node_modules/node-addon-api/nothing.c} +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import commander from './index.js';
|
|
2
|
+
|
|
3
|
+
// wrapper to provide named exports for ESM.
|
|
4
|
+
export const {
|
|
5
|
+
program,
|
|
6
|
+
createCommand,
|
|
7
|
+
createArgument,
|
|
8
|
+
createOption,
|
|
9
|
+
CommanderError,
|
|
10
|
+
InvalidArgumentError,
|
|
11
|
+
InvalidOptionArgumentError, // deprecated old name
|
|
12
|
+
Command,
|
|
13
|
+
Argument,
|
|
14
|
+
Option,
|
|
15
|
+
Help,
|
|
16
|
+
} = commander;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const { Argument } = require('./lib/argument.js');
|
|
2
|
+
const { Command } = require('./lib/command.js');
|
|
3
|
+
const { CommanderError, InvalidArgumentError } = require('./lib/error.js');
|
|
4
|
+
const { Help } = require('./lib/help.js');
|
|
5
|
+
const { Option } = require('./lib/option.js');
|
|
6
|
+
|
|
7
|
+
exports.program = new Command();
|
|
8
|
+
|
|
9
|
+
exports.createCommand = (name) => new Command(name);
|
|
10
|
+
exports.createOption = (flags, description) => new Option(flags, description);
|
|
11
|
+
exports.createArgument = (name, description) => new Argument(name, description);
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Expose classes
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
exports.Command = Command;
|
|
18
|
+
exports.Option = Option;
|
|
19
|
+
exports.Argument = Argument;
|
|
20
|
+
exports.Help = Help;
|
|
21
|
+
|
|
22
|
+
exports.CommanderError = CommanderError;
|
|
23
|
+
exports.InvalidArgumentError = InvalidArgumentError;
|
|
24
|
+
exports.InvalidOptionArgumentError = InvalidArgumentError; // Deprecated
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
const { InvalidArgumentError } = require('./error.js');
|
|
2
|
+
|
|
3
|
+
class Argument {
|
|
4
|
+
/**
|
|
5
|
+
* Initialize a new command argument with the given name and description.
|
|
6
|
+
* The default is that the argument is required, and you can explicitly
|
|
7
|
+
* indicate this with <> around the name. Put [] around the name for an optional argument.
|
|
8
|
+
*
|
|
9
|
+
* @param {string} name
|
|
10
|
+
* @param {string} [description]
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
constructor(name, description) {
|
|
14
|
+
this.description = description || '';
|
|
15
|
+
this.variadic = false;
|
|
16
|
+
this.parseArg = undefined;
|
|
17
|
+
this.defaultValue = undefined;
|
|
18
|
+
this.defaultValueDescription = undefined;
|
|
19
|
+
this.argChoices = undefined;
|
|
20
|
+
|
|
21
|
+
switch (name[0]) {
|
|
22
|
+
case '<': // e.g. <required>
|
|
23
|
+
this.required = true;
|
|
24
|
+
this._name = name.slice(1, -1);
|
|
25
|
+
break;
|
|
26
|
+
case '[': // e.g. [optional]
|
|
27
|
+
this.required = false;
|
|
28
|
+
this._name = name.slice(1, -1);
|
|
29
|
+
break;
|
|
30
|
+
default:
|
|
31
|
+
this.required = true;
|
|
32
|
+
this._name = name;
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (this._name.endsWith('...')) {
|
|
37
|
+
this.variadic = true;
|
|
38
|
+
this._name = this._name.slice(0, -3);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Return argument name.
|
|
44
|
+
*
|
|
45
|
+
* @return {string}
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
name() {
|
|
49
|
+
return this._name;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @package
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
_collectValue(value, previous) {
|
|
57
|
+
if (previous === this.defaultValue || !Array.isArray(previous)) {
|
|
58
|
+
return [value];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
previous.push(value);
|
|
62
|
+
return previous;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Set the default value, and optionally supply the description to be displayed in the help.
|
|
67
|
+
*
|
|
68
|
+
* @param {*} value
|
|
69
|
+
* @param {string} [description]
|
|
70
|
+
* @return {Argument}
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
default(value, description) {
|
|
74
|
+
this.defaultValue = value;
|
|
75
|
+
this.defaultValueDescription = description;
|
|
76
|
+
return this;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Set the custom handler for processing CLI command arguments into argument values.
|
|
81
|
+
*
|
|
82
|
+
* @param {Function} [fn]
|
|
83
|
+
* @return {Argument}
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
argParser(fn) {
|
|
87
|
+
this.parseArg = fn;
|
|
88
|
+
return this;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Only allow argument value to be one of choices.
|
|
93
|
+
*
|
|
94
|
+
* @param {string[]} values
|
|
95
|
+
* @return {Argument}
|
|
96
|
+
*/
|
|
97
|
+
|
|
98
|
+
choices(values) {
|
|
99
|
+
this.argChoices = values.slice();
|
|
100
|
+
this.parseArg = (arg, previous) => {
|
|
101
|
+
if (!this.argChoices.includes(arg)) {
|
|
102
|
+
throw new InvalidArgumentError(
|
|
103
|
+
`Allowed choices are ${this.argChoices.join(', ')}.`,
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
if (this.variadic) {
|
|
107
|
+
return this._collectValue(arg, previous);
|
|
108
|
+
}
|
|
109
|
+
return arg;
|
|
110
|
+
};
|
|
111
|
+
return this;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Make argument required.
|
|
116
|
+
*
|
|
117
|
+
* @returns {Argument}
|
|
118
|
+
*/
|
|
119
|
+
argRequired() {
|
|
120
|
+
this.required = true;
|
|
121
|
+
return this;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Make argument optional.
|
|
126
|
+
*
|
|
127
|
+
* @returns {Argument}
|
|
128
|
+
*/
|
|
129
|
+
argOptional() {
|
|
130
|
+
this.required = false;
|
|
131
|
+
return this;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Takes an argument and returns its human readable equivalent for help usage.
|
|
137
|
+
*
|
|
138
|
+
* @param {Argument} arg
|
|
139
|
+
* @return {string}
|
|
140
|
+
* @private
|
|
141
|
+
*/
|
|
142
|
+
|
|
143
|
+
function humanReadableArgName(arg) {
|
|
144
|
+
const nameOutput = arg.name() + (arg.variadic === true ? '...' : '');
|
|
145
|
+
|
|
146
|
+
return arg.required ? '<' + nameOutput + '>' : '[' + nameOutput + ']';
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
exports.Argument = Argument;
|
|
150
|
+
exports.humanReadableArgName = humanReadableArgName;
|