@henderea/arg-helper 1.2.3 → 1.2.4
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/package.json +7 -4
- package/src/index.d.ts +8 -4
- package/src/index.js +11 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@henderea/arg-helper",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "A utility wrapper around the arg command-line parser",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"author": "Eric Henderson <henderea@gmail.com>",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"scripts": {
|
|
11
|
-
"lint": "eslint src
|
|
12
|
-
"lint:fix": "eslint --fix src
|
|
11
|
+
"lint": "eslint src",
|
|
12
|
+
"lint:fix": "eslint --fix src"
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
15
|
"arg": "5.x"
|
|
@@ -29,6 +29,9 @@
|
|
|
29
29
|
"src/**/*"
|
|
30
30
|
],
|
|
31
31
|
"eslintConfig": {
|
|
32
|
-
"extends": "henderea"
|
|
32
|
+
"extends": "henderea",
|
|
33
|
+
"rules": {
|
|
34
|
+
"@typescript-eslint/ban-types": 0
|
|
35
|
+
}
|
|
33
36
|
}
|
|
34
37
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare function argHelper(arg: any): {argParser: argHelper.argParser};
|
|
1
|
+
declare function argHelper(arg: any): { argParser: argHelper.argParser };
|
|
2
2
|
|
|
3
3
|
declare namespace argHelper {
|
|
4
4
|
export interface Map<V> {
|
|
@@ -19,10 +19,14 @@ declare namespace argHelper {
|
|
|
19
19
|
findVersion(callerPath: string, ...names: Array<string>): this;
|
|
20
20
|
version(packageJsonFile: string, ...names: Array<string>): this;
|
|
21
21
|
parse(argv?: Array<any> | null): Map<any>;
|
|
22
|
-
|
|
22
|
+
get argv(): Map<any>;
|
|
23
|
+
static terminalWidth(multiplier?: number): number;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
export
|
|
26
|
+
export interface argParser {
|
|
27
|
+
(): ArgParser;
|
|
28
|
+
terminalWidth(multiplier?: number): number;
|
|
29
|
+
}
|
|
26
30
|
}
|
|
27
31
|
|
|
28
|
-
export = argHelper;
|
|
32
|
+
export = argHelper;
|
package/src/index.js
CHANGED
|
@@ -79,8 +79,18 @@ class ArgParser {
|
|
|
79
79
|
get argv() {
|
|
80
80
|
return this.parse();
|
|
81
81
|
}
|
|
82
|
+
|
|
83
|
+
static terminalWidth(multiplier = 1) {
|
|
84
|
+
const cols = process.stdout.columns;
|
|
85
|
+
if(cols) {
|
|
86
|
+
return Math.round(cols * multiplier);
|
|
87
|
+
}
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
82
90
|
}
|
|
83
91
|
|
|
84
92
|
module.exports = (arg) => {
|
|
85
|
-
|
|
93
|
+
const argParser = () => new ArgParser(arg);
|
|
94
|
+
argParser.terminalWidth = ArgParser.terminalWidth;
|
|
95
|
+
return { argParser };
|
|
86
96
|
};
|