cli-argv-util 1.0.0 → 1.1.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/dist/cli-argv-util.d.ts +1 -1
- package/dist/cli-argv-util.js +1 -1
- package/package.json +15 -16
- package/dist/cli-argv-util.umd.cjs +0 -39
package/dist/cli-argv-util.d.ts
CHANGED
package/dist/cli-argv-util.js
CHANGED
package/package.json
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cli-argv-util",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Simple utility to parse command line parameters and flags (arguments vector)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"module": "dist/cli-argv-util.js",
|
|
8
|
-
"main": "dist/cli-argv-util.
|
|
8
|
+
"main": "dist/cli-argv-util.js",
|
|
9
9
|
"types": "dist/cli-argv-util.d.ts",
|
|
10
10
|
"files": [
|
|
11
11
|
"dist"
|
|
12
12
|
],
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
15
|
-
"import": "./dist/cli-argv-util.js"
|
|
16
|
-
"require": "./dist/cli-argv-util.umd.cjs"
|
|
15
|
+
"import": "./dist/cli-argv-util.js"
|
|
17
16
|
},
|
|
18
17
|
"./": "./dist/"
|
|
19
18
|
},
|
|
@@ -58,32 +57,32 @@
|
|
|
58
57
|
}
|
|
59
58
|
},
|
|
60
59
|
"runScriptsConfig": {
|
|
60
|
+
"clean": [
|
|
61
|
+
"rimraf build dist"
|
|
62
|
+
],
|
|
61
63
|
"build": [
|
|
62
|
-
"rimraf build dist **/.DS_Store",
|
|
63
64
|
"jshint . --exclude-path .gitignore",
|
|
64
65
|
"eslint --max-warnings 0 . --ext .ts",
|
|
65
66
|
"tsc",
|
|
66
|
-
"tsc --module UMD --outDir build/umd",
|
|
67
|
-
"copy-file build/umd/cli-argv-util.js build/cli-argv-util.umd.cjs",
|
|
68
67
|
"add-dist-header build dist"
|
|
69
68
|
]
|
|
70
69
|
},
|
|
71
70
|
"scripts": {
|
|
72
|
-
"pretest": "run-scripts build",
|
|
71
|
+
"pretest": "run-scripts clean build",
|
|
73
72
|
"test": "mocha spec/*.spec.js"
|
|
74
73
|
},
|
|
75
74
|
"devDependencies": {
|
|
76
|
-
"@types/node": "~
|
|
77
|
-
"@typescript-eslint/eslint-plugin": "~5.
|
|
78
|
-
"@typescript-eslint/parser": "~5.
|
|
75
|
+
"@types/node": "~20.3",
|
|
76
|
+
"@typescript-eslint/eslint-plugin": "~5.60",
|
|
77
|
+
"@typescript-eslint/parser": "~5.60",
|
|
79
78
|
"add-dist-header": "~1.0",
|
|
80
79
|
"assert-deep-strict-equal": "~1.0",
|
|
81
|
-
"copy-file-util": "~
|
|
82
|
-
"eslint": "~8.
|
|
80
|
+
"copy-file-util": "~1.1",
|
|
81
|
+
"eslint": "~8.43",
|
|
83
82
|
"jshint": "~2.13",
|
|
84
83
|
"mocha": "~10.2",
|
|
85
|
-
"rimraf": "
|
|
86
|
-
"run-scripts-util": "~
|
|
87
|
-
"typescript": "~
|
|
84
|
+
"rimraf": "~5.0",
|
|
85
|
+
"run-scripts-util": "~1.1",
|
|
86
|
+
"typescript": "~5.1"
|
|
88
87
|
}
|
|
89
88
|
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
//! cli-argv-util v1.0.0 ~~ https://github.com/center-key/cli-argv-util ~~ MIT License
|
|
2
|
-
|
|
3
|
-
(function (factory) {
|
|
4
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
5
|
-
var v = factory(require, exports);
|
|
6
|
-
if (v !== undefined) module.exports = v;
|
|
7
|
-
}
|
|
8
|
-
else if (typeof define === "function" && define.amd) {
|
|
9
|
-
define(["require", "exports"], factory);
|
|
10
|
-
}
|
|
11
|
-
})(function (require, exports) {
|
|
12
|
-
"use strict";
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.cliArgvUtil = void 0;
|
|
15
|
-
const cliArgvUtil = {
|
|
16
|
-
parse(validFlags) {
|
|
17
|
-
var _a, _b;
|
|
18
|
-
const toCamel = (token) => token.replace(/-./g, char => char[1].toUpperCase());
|
|
19
|
-
const toEntry = (pair) => [toCamel(pair[0]), pair[1]];
|
|
20
|
-
const toPair = (flag) => flag.replace(/^--/, '').split('=');
|
|
21
|
-
const args = process.argv.slice(2);
|
|
22
|
-
const pairs = args.filter(arg => /^--/.test(arg)).map(toPair);
|
|
23
|
-
const flagMap = Object.fromEntries(pairs.map(toEntry));
|
|
24
|
-
const onEntries = validFlags.map(flag => [toCamel(flag), toCamel(flag) in flagMap]);
|
|
25
|
-
const invalidFlag = (_b = (_a = pairs.find(pair => !validFlags.includes(pair[0]))) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : null;
|
|
26
|
-
const helpMsg = '\nValid flags are --' + validFlags.join(' --');
|
|
27
|
-
const params = args.filter(arg => !/^--/.test(arg));
|
|
28
|
-
return {
|
|
29
|
-
flagMap: flagMap,
|
|
30
|
-
flagOn: Object.fromEntries(onEntries),
|
|
31
|
-
invalidFlag: invalidFlag,
|
|
32
|
-
invalidFlagMsg: invalidFlag ? 'Invalid flag: --' + invalidFlag + helpMsg : null,
|
|
33
|
-
params: params,
|
|
34
|
-
paramCount: params.length,
|
|
35
|
-
};
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
exports.cliArgvUtil = cliArgvUtil;
|
|
39
|
-
});
|