@mojir/lits 2.5.0 → 2.5.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.
- package/dist/cli/cli.js +63 -39
- package/package.json +1 -1
package/dist/cli/cli.js
CHANGED
|
@@ -7,7 +7,7 @@ var readline = require('node:readline');
|
|
|
7
7
|
var os = require('node:os');
|
|
8
8
|
var process$1 = require('node:process');
|
|
9
9
|
|
|
10
|
-
var version = "2.5.
|
|
10
|
+
var version = "2.5.1";
|
|
11
11
|
|
|
12
12
|
function getCodeMarker(sourceCodeInfo) {
|
|
13
13
|
if (!sourceCodeInfo.position || !sourceCodeInfo.code)
|
|
@@ -34668,6 +34668,7 @@ const HIST_SIZE = 1000;
|
|
|
34668
34668
|
const PROMPT = fmt.bright.gray('> ');
|
|
34669
34669
|
const historyResults = [];
|
|
34670
34670
|
const formatValue = getInlineCodeFormatter(fmt);
|
|
34671
|
+
const booleanFlags = new Set(['-s', '--silent', '--pure']);
|
|
34671
34672
|
const commands = ['`help', '`quit', '`builtins', '`context'];
|
|
34672
34673
|
const expressionRegExp = new RegExp(`^(.*\\(\\s*)(${polishSymbolFirstCharacterClass}${polishSymbolCharacterClass}*)$`);
|
|
34673
34674
|
const nameRegExp = new RegExp(`^(.*?)(${polishSymbolFirstCharacterClass}${polishSymbolCharacterClass}*)$`);
|
|
@@ -34846,14 +34847,26 @@ function setReplHistoryVariables(context) {
|
|
|
34846
34847
|
}
|
|
34847
34848
|
function parseOption(args, i) {
|
|
34848
34849
|
const option = args[i];
|
|
34849
|
-
|
|
34850
|
-
|
|
34851
|
-
|
|
34852
|
-
|
|
34850
|
+
// Short option: -x
|
|
34851
|
+
if (/^-[a-z]$/i.test(option)) {
|
|
34852
|
+
if (booleanFlags.has(option)) {
|
|
34853
|
+
return { option, argument: null, count: 1 };
|
|
34854
|
+
}
|
|
34853
34855
|
return { option, argument: args[i + 1] ?? null, count: 2 };
|
|
34856
|
+
}
|
|
34857
|
+
// Long option: --foo or --foo=value
|
|
34854
34858
|
const match = /^(--[a-z-]+)(?:=(.*))?$/i.exec(option);
|
|
34855
|
-
if (match)
|
|
34856
|
-
|
|
34859
|
+
if (match) {
|
|
34860
|
+
const name = match[1];
|
|
34861
|
+
const inlineArg = match[2];
|
|
34862
|
+
if (inlineArg !== undefined) {
|
|
34863
|
+
return { option: name, argument: inlineArg, count: 1 };
|
|
34864
|
+
}
|
|
34865
|
+
if (booleanFlags.has(name)) {
|
|
34866
|
+
return { option: name, argument: null, count: 1 };
|
|
34867
|
+
}
|
|
34868
|
+
return { option: name, argument: args[i + 1] ?? null, count: 2 };
|
|
34869
|
+
}
|
|
34857
34870
|
return null;
|
|
34858
34871
|
}
|
|
34859
34872
|
function parseContextOptions(args, startIndex) {
|
|
@@ -34928,11 +34941,19 @@ function parseRunEvalOptions(args, startIndex) {
|
|
|
34928
34941
|
let context = {};
|
|
34929
34942
|
let printResult = true;
|
|
34930
34943
|
let pure = false;
|
|
34944
|
+
let positional = null;
|
|
34931
34945
|
let i = startIndex;
|
|
34932
34946
|
while (i < args.length) {
|
|
34933
34947
|
const parsed = parseOption(args, i);
|
|
34934
|
-
if (!parsed)
|
|
34935
|
-
|
|
34948
|
+
if (!parsed) {
|
|
34949
|
+
if (positional !== null) {
|
|
34950
|
+
printErrorMessage(`Unexpected argument "${args[i]}"`);
|
|
34951
|
+
process.exit(1);
|
|
34952
|
+
}
|
|
34953
|
+
positional = args[i];
|
|
34954
|
+
i += 1;
|
|
34955
|
+
continue;
|
|
34956
|
+
}
|
|
34936
34957
|
switch (parsed.option) {
|
|
34937
34958
|
case '-c':
|
|
34938
34959
|
case '--context':
|
|
@@ -34959,11 +34980,7 @@ function parseRunEvalOptions(args, startIndex) {
|
|
|
34959
34980
|
process.exit(1);
|
|
34960
34981
|
}
|
|
34961
34982
|
}
|
|
34962
|
-
|
|
34963
|
-
printErrorMessage(`Unknown argument "${args[i]}"`);
|
|
34964
|
-
process.exit(1);
|
|
34965
|
-
}
|
|
34966
|
-
return { context, printResult, pure, nextIndex: i };
|
|
34983
|
+
return { context, printResult, pure, positional, nextIndex: i };
|
|
34967
34984
|
}
|
|
34968
34985
|
function processArguments(args) {
|
|
34969
34986
|
// Global flags (no subcommand)
|
|
@@ -34979,45 +34996,43 @@ function processArguments(args) {
|
|
|
34979
34996
|
}
|
|
34980
34997
|
switch (first) {
|
|
34981
34998
|
case 'run': {
|
|
34982
|
-
const filename = args
|
|
34983
|
-
if (!filename
|
|
34999
|
+
const { positional: filename, context, printResult, pure } = parseRunEvalOptions(args, 1);
|
|
35000
|
+
if (!filename) {
|
|
34984
35001
|
printErrorMessage('Missing filename after "run"');
|
|
34985
35002
|
process.exit(1);
|
|
34986
35003
|
}
|
|
34987
|
-
const { context, printResult, pure } = parseRunEvalOptions(args, 2);
|
|
34988
35004
|
return { subcommand: 'run', filename, context, printResult, pure };
|
|
34989
35005
|
}
|
|
34990
35006
|
case 'run-bundle': {
|
|
34991
|
-
const filename = args
|
|
34992
|
-
if (!filename
|
|
35007
|
+
const { positional: filename, context, printResult, pure } = parseRunEvalOptions(args, 1);
|
|
35008
|
+
if (!filename) {
|
|
34993
35009
|
printErrorMessage('Missing filename after "run-bundle"');
|
|
34994
35010
|
process.exit(1);
|
|
34995
35011
|
}
|
|
34996
|
-
const { context, printResult, pure } = parseRunEvalOptions(args, 2);
|
|
34997
35012
|
return { subcommand: 'run-bundle', filename, context, printResult, pure };
|
|
34998
35013
|
}
|
|
34999
35014
|
case 'eval': {
|
|
35000
|
-
const expression = args
|
|
35001
|
-
if (!expression
|
|
35015
|
+
const { positional: expression, context, printResult, pure } = parseRunEvalOptions(args, 1);
|
|
35016
|
+
if (!expression) {
|
|
35002
35017
|
printErrorMessage('Missing expression after "eval"');
|
|
35003
35018
|
process.exit(1);
|
|
35004
35019
|
}
|
|
35005
|
-
const { context, printResult, pure } = parseRunEvalOptions(args, 2);
|
|
35006
35020
|
return { subcommand: 'eval', expression, context, printResult, pure };
|
|
35007
35021
|
}
|
|
35008
35022
|
case 'bundle': {
|
|
35009
|
-
|
|
35010
|
-
if (!filename || filename.startsWith('-')) {
|
|
35011
|
-
printErrorMessage('Missing filename after "bundle"');
|
|
35012
|
-
process.exit(1);
|
|
35013
|
-
}
|
|
35023
|
+
let filename = null;
|
|
35014
35024
|
let output = null;
|
|
35015
|
-
let i =
|
|
35025
|
+
let i = 1;
|
|
35016
35026
|
while (i < args.length) {
|
|
35017
35027
|
const parsed = parseOption(args, i);
|
|
35018
35028
|
if (!parsed) {
|
|
35019
|
-
|
|
35020
|
-
|
|
35029
|
+
if (filename !== null) {
|
|
35030
|
+
printErrorMessage(`Unexpected argument "${args[i]}"`);
|
|
35031
|
+
process.exit(1);
|
|
35032
|
+
}
|
|
35033
|
+
filename = args[i];
|
|
35034
|
+
i += 1;
|
|
35035
|
+
continue;
|
|
35021
35036
|
}
|
|
35022
35037
|
switch (parsed.option) {
|
|
35023
35038
|
case '-o':
|
|
@@ -35034,21 +35049,26 @@ function processArguments(args) {
|
|
|
35034
35049
|
process.exit(1);
|
|
35035
35050
|
}
|
|
35036
35051
|
}
|
|
35052
|
+
if (!filename) {
|
|
35053
|
+
printErrorMessage('Missing filename after "bundle"');
|
|
35054
|
+
process.exit(1);
|
|
35055
|
+
}
|
|
35037
35056
|
return { subcommand: 'bundle', filename, output };
|
|
35038
35057
|
}
|
|
35039
35058
|
case 'test': {
|
|
35040
|
-
|
|
35041
|
-
if (!filename || filename.startsWith('-')) {
|
|
35042
|
-
printErrorMessage('Missing filename after "test"');
|
|
35043
|
-
process.exit(1);
|
|
35044
|
-
}
|
|
35059
|
+
let filename = null;
|
|
35045
35060
|
let testPattern = null;
|
|
35046
|
-
let i =
|
|
35061
|
+
let i = 1;
|
|
35047
35062
|
while (i < args.length) {
|
|
35048
35063
|
const parsed = parseOption(args, i);
|
|
35049
35064
|
if (!parsed) {
|
|
35050
|
-
|
|
35051
|
-
|
|
35065
|
+
if (filename !== null) {
|
|
35066
|
+
printErrorMessage(`Unexpected argument "${args[i]}"`);
|
|
35067
|
+
process.exit(1);
|
|
35068
|
+
}
|
|
35069
|
+
filename = args[i];
|
|
35070
|
+
i += 1;
|
|
35071
|
+
continue;
|
|
35052
35072
|
}
|
|
35053
35073
|
switch (parsed.option) {
|
|
35054
35074
|
case '--pattern':
|
|
@@ -35064,6 +35084,10 @@ function processArguments(args) {
|
|
|
35064
35084
|
process.exit(1);
|
|
35065
35085
|
}
|
|
35066
35086
|
}
|
|
35087
|
+
if (!filename) {
|
|
35088
|
+
printErrorMessage('Missing filename after "test"');
|
|
35089
|
+
process.exit(1);
|
|
35090
|
+
}
|
|
35067
35091
|
return { subcommand: 'test', filename, testPattern };
|
|
35068
35092
|
}
|
|
35069
35093
|
case 'repl': {
|