Comparing version 0.10.0 to 0.11.0
@@ -114,3 +114,3 @@ "use strict"; | ||
* Runs the lexer, matching a prefix and command. | ||
* This consumes at least two tokens of the lexer. | ||
* This consumes at most two tokens of the lexer. | ||
* @param matchPrefix - A function that gives the length of the prefix if there is one. | ||
@@ -117,0 +117,0 @@ * @returns The command and the rest of the lexed tokens, as long as the prefix was matched. |
@@ -24,13 +24,3 @@ "use strict"; | ||
function longStrategy() { | ||
return { | ||
matchFlag: (s) => { var _a, _b; return (_b = (_a = s.match(/^--([^=]+)$/)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : null; }, | ||
matchOption: (s) => { var _a, _b; return (_b = (_a = s.match(/^--(.+)=$/)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : null; }, | ||
matchCompactOption: (s) => { | ||
const m = s.match(/^--(.+)=(.+)$/); | ||
if (m == null) { | ||
return null; | ||
} | ||
return [m[1], m[2]]; | ||
} | ||
}; | ||
return prefixedStrategy(['--'], ['=']); | ||
} | ||
@@ -40,19 +30,9 @@ exports.longStrategy = longStrategy; | ||
* Match unordered arguments according to conventional syntax. | ||
* '--flag' or '-f' is a flag. | ||
* '--opt=' is an option. | ||
* '--opt=123' or '-o123' is a compact option. | ||
* '--flag' or '-flag' is a flag. | ||
* '--opt=' or '-opt=' is an option. | ||
* '--opt=123' or '-opt=123' is a compact option. | ||
* @returns The strategy. | ||
*/ | ||
function longShortStrategy() { | ||
return { | ||
matchFlag: (s) => { var _a, _b, _c, _d; return (_d = (_b = (_a = s.match(/^--([^=]+)$/)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : (_c = s.match(/^-([^=])$/)) === null || _c === void 0 ? void 0 : _c[1]) !== null && _d !== void 0 ? _d : null; }, | ||
matchOption: (s) => { var _a, _b; return (_b = (_a = s.match(/^--(.+)=$/)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : null; }, | ||
matchCompactOption: (s) => { | ||
const m = s.match(/^--(.+)=(.+)$/) || s.match(/^-([^-])(.+)$/); | ||
if (m == null) { | ||
return null; | ||
} | ||
return [m[1], m[2]]; | ||
} | ||
}; | ||
return prefixedStrategy(['--', '-'], ['=']); | ||
} | ||
@@ -65,3 +45,5 @@ exports.longShortStrategy = longShortStrategy; | ||
* @param prefixes - The prefixes to use for unordered arguments. | ||
* @param separators - The symbol to use to separate the key and value in options. | ||
* They should be ordered by length in non-increasing order. | ||
* @param separators - The symbols to use to separate the key and value in options. | ||
* They should be ordered by length in non-increasing order. | ||
* @returns The strategy. | ||
@@ -122,2 +104,3 @@ */ | ||
* @param compactOptions - Words usable as the key of compact options. | ||
* They should be ordered by length in non-increasing order. | ||
* @returns The strategy. | ||
@@ -156,2 +139,3 @@ */ | ||
* @param compactOptions - Words usable as the key of compact options. | ||
* They should be ordered by length in non-increasing order. | ||
* @param locale - The locale(s) to use to compare case. | ||
@@ -158,0 +142,0 @@ * @returns The strategy. |
@@ -45,3 +45,3 @@ import { Token, MatchPrefix } from './tokens'; | ||
* Runs the lexer, matching a prefix and command. | ||
* This consumes at least two tokens of the lexer. | ||
* This consumes at most two tokens of the lexer. | ||
* @param matchPrefix - A function that gives the length of the prefix if there is one. | ||
@@ -48,0 +48,0 @@ * @returns The command and the rest of the lexed tokens, as long as the prefix was matched. |
@@ -39,5 +39,5 @@ /** | ||
* Match unordered arguments according to conventional syntax. | ||
* '--flag' or '-f' is a flag. | ||
* '--opt=' is an option. | ||
* '--opt=123' or '-o123' is a compact option. | ||
* '--flag' or '-flag' is a flag. | ||
* '--opt=' or '-opt=' is an option. | ||
* '--opt=123' or '-opt=123' is a compact option. | ||
* @returns The strategy. | ||
@@ -51,3 +51,5 @@ */ | ||
* @param prefixes - The prefixes to use for unordered arguments. | ||
* @param separators - The symbol to use to separate the key and value in options. | ||
* They should be ordered by length in non-increasing order. | ||
* @param separators - The symbols to use to separate the key and value in options. | ||
* They should be ordered by length in non-increasing order. | ||
* @returns The strategy. | ||
@@ -66,2 +68,3 @@ */ | ||
* @param compactOptions - Words usable as the key of compact options. | ||
* They should be ordered by length in non-increasing order. | ||
* @returns The strategy. | ||
@@ -76,2 +79,3 @@ */ | ||
* @param compactOptions - Words usable as the key of compact options. | ||
* They should be ordered by length in non-increasing order. | ||
* @param locale - The locale(s) to use to compare case. | ||
@@ -78,0 +82,0 @@ * @returns The strategy. |
{ | ||
"name": "lexure", | ||
"version": "0.10.0", | ||
"version": "0.11.0", | ||
"description": "Parser and utilities for non-technical user input.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
93604
1787