massarg 1.0.6 → 2.0.0-pre.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/README.md +119 -98
- package/command.d.ts +153 -0
- package/command.d.ts.map +1 -0
- package/command.js +317 -0
- package/command.js.map +1 -0
- package/error.d.ts +34 -0
- package/error.d.ts.map +1 -0
- package/error.js +37 -0
- package/error.js.map +1 -0
- package/example.d.ts +31 -0
- package/example.d.ts.map +1 -0
- package/example.js +41 -0
- package/example.js.map +1 -0
- package/help.d.ts +729 -0
- package/help.d.ts.map +1 -0
- package/help.js +253 -0
- package/help.js.map +1 -0
- package/index.d.ts +1 -70
- package/index.d.ts.map +1 -1
- package/index.js +13 -673
- package/index.js.map +1 -1
- package/massarg.d.ts +8 -0
- package/massarg.d.ts.map +1 -0
- package/massarg.js +23 -0
- package/massarg.js.map +1 -0
- package/option.d.ts +241 -0
- package/option.d.ts.map +1 -0
- package/option.js +305 -0
- package/option.js.map +1 -0
- package/package.json +22 -14
- package/style.d.ts +45 -0
- package/style.d.ts.map +1 -0
- package/style.js +52 -0
- package/style.js.map +1 -0
- package/utils.d.ts +33 -13
- package/utils.d.ts.map +1 -1
- package/utils.js +97 -110
- package/utils.js.map +1 -1
- package/assertions.d.ts +0 -8
- package/assertions.d.ts.map +0 -1
- package/assertions.js +0 -145
- package/assertions.js.map +0 -1
- package/errors.d.ts +0 -7
- package/errors.d.ts.map +0 -1
- package/errors.js +0 -33
- package/errors.js.map +0 -1
- package/types.d.ts +0 -224
- package/types.d.ts.map +0 -1
- package/types.js +0 -3
- package/types.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "massarg",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-pre.1",
|
|
4
4
|
"description": "Flexible, powerful, and simple command/argument parser for CLI applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"shell",
|
|
@@ -15,22 +15,30 @@
|
|
|
15
15
|
"author": "Chen Asraf <chenasrafil@gmail.com>",
|
|
16
16
|
"license": "Apache",
|
|
17
17
|
"scripts": {
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"test": "jest"
|
|
18
|
+
"build": "tsc -p tsconfig.build.json && cp package.json README.md build",
|
|
19
|
+
"dev": "tsc --watch",
|
|
20
|
+
"cmd": "ts-node src/sample.ts",
|
|
21
|
+
"test": "jest",
|
|
22
|
+
"doc": "typedoc --out docs src/**/*.ts --exclude src/sample.ts --plugin typedoc-plugin-zod --theme default",
|
|
23
|
+
"deploy-doc": "pnpm doc && gh-pages -d docs",
|
|
24
|
+
"semantic-release": "semantic-release"
|
|
22
25
|
},
|
|
23
26
|
"devDependencies": {
|
|
24
|
-
"@
|
|
25
|
-
"@
|
|
26
|
-
"@
|
|
27
|
-
"jest": "^
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
27
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
28
|
+
"@semantic-release/exec": "^6.0.3",
|
|
29
|
+
"@semantic-release/git": "^10.0.1",
|
|
30
|
+
"@types/jest": "^29.5.8",
|
|
31
|
+
"@types/node": "^20.9.2",
|
|
32
|
+
"gh-pages": "^6.1.0",
|
|
33
|
+
"jest": "^29.7.0",
|
|
34
|
+
"semantic-release": "^22.0.8",
|
|
35
|
+
"ts-jest": "^29.1.1",
|
|
36
|
+
"ts-node": "^10.9.1",
|
|
37
|
+
"typedoc": "^0.25.3",
|
|
38
|
+
"typedoc-plugin-zod": "^1.1.0",
|
|
39
|
+
"typescript": "^5.2.2"
|
|
31
40
|
},
|
|
32
41
|
"dependencies": {
|
|
33
|
-
"
|
|
34
|
-
"lodash": "^4.17.21"
|
|
42
|
+
"zod": "^3.22.4"
|
|
35
43
|
}
|
|
36
44
|
}
|
package/style.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
export declare const ansiStyles: {
|
|
3
|
+
reset: string;
|
|
4
|
+
bold: string;
|
|
5
|
+
underline: string;
|
|
6
|
+
black: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const ansiColors: {
|
|
9
|
+
red: string;
|
|
10
|
+
green: string;
|
|
11
|
+
yellow: string;
|
|
12
|
+
blue: string;
|
|
13
|
+
magenta: string;
|
|
14
|
+
cyan: string;
|
|
15
|
+
white: string;
|
|
16
|
+
gray: string;
|
|
17
|
+
grey: string;
|
|
18
|
+
brightRed: string;
|
|
19
|
+
brightGreen: string;
|
|
20
|
+
brightYellow: string;
|
|
21
|
+
brightBlue: string;
|
|
22
|
+
brightMagenta: string;
|
|
23
|
+
brightCyan: string;
|
|
24
|
+
brightWhite: string;
|
|
25
|
+
};
|
|
26
|
+
export declare const StringStyle: z.ZodObject<{
|
|
27
|
+
bold: z.ZodOptional<z.ZodBoolean>;
|
|
28
|
+
underline: z.ZodOptional<z.ZodBoolean>;
|
|
29
|
+
color: z.ZodOptional<z.ZodEnum<["red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "grey" | "brightRed" | "brightGreen" | "brightYellow" | "brightBlue" | "brightMagenta" | "brightCyan" | "brightWhite", ...("red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "grey" | "brightRed" | "brightGreen" | "brightYellow" | "brightBlue" | "brightMagenta" | "brightCyan" | "brightWhite")[]]>>;
|
|
30
|
+
reset: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
31
|
+
}, "strip", z.ZodTypeAny, {
|
|
32
|
+
bold?: boolean | undefined;
|
|
33
|
+
underline?: boolean | undefined;
|
|
34
|
+
color?: "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "grey" | "brightRed" | "brightGreen" | "brightYellow" | "brightBlue" | "brightMagenta" | "brightCyan" | "brightWhite" | undefined;
|
|
35
|
+
reset?: boolean | undefined;
|
|
36
|
+
}, {
|
|
37
|
+
bold?: boolean | undefined;
|
|
38
|
+
underline?: boolean | undefined;
|
|
39
|
+
color?: "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "grey" | "brightRed" | "brightGreen" | "brightYellow" | "brightBlue" | "brightMagenta" | "brightCyan" | "brightWhite" | undefined;
|
|
40
|
+
reset?: boolean | undefined;
|
|
41
|
+
}>;
|
|
42
|
+
export type StringStyle = z.infer<typeof StringStyle>;
|
|
43
|
+
export declare function format(string: string, style?: StringStyle): string;
|
|
44
|
+
export declare function stripStyle(string: string): string;
|
|
45
|
+
//# sourceMappingURL=style.d.ts.map
|
package/style.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../src/style.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAA;AAGnB,eAAO,MAAM,UAAU;;;;;CAKtB,CAAA;AAED,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;CAiBtB,CAAA;AAED,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;EAKtB,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAA;AAErD,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,GAAE,WAAgB,GAAG,MAAM,CAOtE;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEjD"}
|
package/style.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.stripStyle = exports.format = exports.StringStyle = exports.ansiColors = exports.ansiStyles = void 0;
|
|
7
|
+
const zod_1 = __importDefault(require("zod"));
|
|
8
|
+
const utils_1 = require("./utils");
|
|
9
|
+
exports.ansiStyles = {
|
|
10
|
+
reset: '\x1b[0m',
|
|
11
|
+
bold: '\x1b[1m',
|
|
12
|
+
underline: '\x1b[4m',
|
|
13
|
+
black: '\x1b[30m',
|
|
14
|
+
};
|
|
15
|
+
exports.ansiColors = {
|
|
16
|
+
red: '\x1b[31m',
|
|
17
|
+
green: '\x1b[32m',
|
|
18
|
+
yellow: '\x1b[33m',
|
|
19
|
+
blue: '\x1b[34m',
|
|
20
|
+
magenta: '\x1b[35m',
|
|
21
|
+
cyan: '\x1b[36m',
|
|
22
|
+
white: '\x1b[37m',
|
|
23
|
+
gray: '\x1b[90m',
|
|
24
|
+
grey: '\x1b[90m',
|
|
25
|
+
brightRed: '\x1b[91m',
|
|
26
|
+
brightGreen: '\x1b[92m',
|
|
27
|
+
brightYellow: '\x1b[93m',
|
|
28
|
+
brightBlue: '\x1b[94m',
|
|
29
|
+
brightMagenta: '\x1b[95m',
|
|
30
|
+
brightCyan: '\x1b[96m',
|
|
31
|
+
brightWhite: '\x1b[97m',
|
|
32
|
+
};
|
|
33
|
+
exports.StringStyle = zod_1.default.object({
|
|
34
|
+
bold: zod_1.default.boolean().optional(),
|
|
35
|
+
underline: zod_1.default.boolean().optional(),
|
|
36
|
+
color: (0, utils_1.zodEnumFromObjKeys)(exports.ansiColors).optional(),
|
|
37
|
+
reset: zod_1.default.boolean().default(true).optional(),
|
|
38
|
+
});
|
|
39
|
+
function format(string, style = {}) {
|
|
40
|
+
const { color, bold, underline, reset = true } = style;
|
|
41
|
+
const colorCode = color ? exports.ansiColors[color] : '';
|
|
42
|
+
const boldCode = bold ? exports.ansiStyles.bold : '';
|
|
43
|
+
const underlineCode = underline ? exports.ansiStyles.underline : '';
|
|
44
|
+
const resetCode = reset ? exports.ansiStyles.reset : '';
|
|
45
|
+
return `${colorCode}${boldCode}${underlineCode}${string}${resetCode}`;
|
|
46
|
+
}
|
|
47
|
+
exports.format = format;
|
|
48
|
+
function stripStyle(string) {
|
|
49
|
+
return string.replace(/\x1b\[\d+m/gi, '');
|
|
50
|
+
}
|
|
51
|
+
exports.stripStyle = stripStyle;
|
|
52
|
+
//# sourceMappingURL=style.js.map
|
package/style.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.js","sourceRoot":"","sources":["../src/style.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAmB;AACnB,mCAA4C;AAE/B,QAAA,UAAU,GAAG;IACxB,KAAK,EAAE,SAAS;IAChB,IAAI,EAAE,SAAS;IACf,SAAS,EAAE,SAAS;IACpB,KAAK,EAAE,UAAU;CAClB,CAAA;AAEY,QAAA,UAAU,GAAG;IACxB,GAAG,EAAE,UAAU;IACf,KAAK,EAAE,UAAU;IACjB,MAAM,EAAE,UAAU;IAClB,IAAI,EAAE,UAAU;IAChB,OAAO,EAAE,UAAU;IACnB,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,UAAU;IACjB,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,UAAU;IAChB,SAAS,EAAE,UAAU;IACrB,WAAW,EAAE,UAAU;IACvB,YAAY,EAAE,UAAU;IACxB,UAAU,EAAE,UAAU;IACtB,aAAa,EAAE,UAAU;IACzB,UAAU,EAAE,UAAU;IACtB,WAAW,EAAE,UAAU;CACxB,CAAA;AAEY,QAAA,WAAW,GAAG,aAAC,CAAC,MAAM,CAAC;IAClC,IAAI,EAAE,aAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC5B,SAAS,EAAE,aAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACjC,KAAK,EAAE,IAAA,0BAAkB,EAAC,kBAAU,CAAC,CAAC,QAAQ,EAAE;IAChD,KAAK,EAAE,aAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE;CAC5C,CAAC,CAAA;AAIF,SAAgB,MAAM,CAAC,MAAc,EAAE,QAAqB,EAAE;IAC5D,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,KAAK,CAAA;IACtD,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,kBAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IAChD,MAAM,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,kBAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAA;IAC5C,MAAM,aAAa,GAAG,SAAS,CAAC,CAAC,CAAC,kBAAU,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAA;IAC3D,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,kBAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA;IAC/C,OAAO,GAAG,SAAS,GAAG,QAAQ,GAAG,aAAa,GAAG,MAAM,GAAG,SAAS,EAAE,CAAA;AACvE,CAAC;AAPD,wBAOC;AAED,SAAgB,UAAU,CAAC,MAAc;IACvC,OAAO,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAA;AAC3C,CAAC;AAFD,gCAEC"}
|
package/utils.d.ts
CHANGED
|
@@ -1,14 +1,34 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export declare function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
/** @internal */
|
|
3
|
+
export declare function setOrPush<T>(newValue: unknown, currentValue: T[] | T | undefined, isArray: boolean): T;
|
|
4
|
+
type Parseable = string | number | boolean | null | undefined | Record<string, unknown>;
|
|
5
|
+
/** A type that makes all properties of an object required, recursively. */
|
|
6
|
+
export type DeepRequired<T> = {
|
|
7
|
+
[P in keyof T]-?: T[P] extends object ? DeepRequired<T[P]> : NonNullable<T[P]>;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Concatenates strings, arrays of strings, and objects with truthy values.
|
|
11
|
+
*
|
|
12
|
+
* It works recursively, so adding an array of strings to an array of strings will work.
|
|
13
|
+
*
|
|
14
|
+
* Falsy values are ignored, so pasing `undefined` or `null` will not add anything to the result,
|
|
15
|
+
* and using a boolean will only add it if it is `true`. Using 0 will also not add anything.
|
|
16
|
+
*/
|
|
17
|
+
export declare function strConcat(...strs: (Parseable | Parseable[])[]): string;
|
|
18
|
+
/**
|
|
19
|
+
* Indents a string or an array of strings. Concatenates them all using `strConcat`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function indent(str: Parseable | Parseable[], indent?: number): string;
|
|
22
|
+
/** @internal */
|
|
23
|
+
export declare function zodEnumFromObjKeys<K extends string>(obj: Record<K, any>): z.ZodEnum<[K, ...K[]]>;
|
|
24
|
+
/** @internal */
|
|
25
|
+
export declare function deepMerge<T1, T2>(obj1: T1, obj2: T2): NonNullable<T1> & NonNullable<T2>;
|
|
26
|
+
/**
|
|
27
|
+
* Splits a name into words, using camelCase, PascalCase, snake_case, and kebab-case or
|
|
28
|
+
* regular spaced strings.
|
|
29
|
+
*/
|
|
30
|
+
export declare function splitWords(str: string): string[];
|
|
31
|
+
export declare function toCamelCase(str: string): string;
|
|
32
|
+
export declare function toPascalCase(str: string): string;
|
|
33
|
+
export {};
|
|
14
34
|
//# sourceMappingURL=utils.d.ts.map
|
package/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAA;AAEnB,gBAAgB;AAChB,wBAAgB,SAAS,CAAC,CAAC,EACzB,QAAQ,EAAE,OAAO,EACjB,YAAY,EAAE,CAAC,EAAE,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,MAAM,CAIhD"}
|
package/utils.js
CHANGED
|
@@ -1,129 +1,116 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __values = (this && this.__values) || function(o) {
|
|
3
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
4
|
-
if (m) return m.call(o);
|
|
5
|
-
if (o && typeof o.length === "number") return {
|
|
6
|
-
next: function () {
|
|
7
|
-
if (o && i >= o.length) o = void 0;
|
|
8
|
-
return { value: o && o[i++], done: !o };
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
12
|
-
};
|
|
13
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
14
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
15
|
-
if (!m) return o;
|
|
16
|
-
var i = m.call(o), r, ar = [], e;
|
|
17
|
-
try {
|
|
18
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
19
|
-
}
|
|
20
|
-
catch (error) { e = { error: error }; }
|
|
21
|
-
finally {
|
|
22
|
-
try {
|
|
23
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
24
|
-
}
|
|
25
|
-
finally { if (e) throw e.error; }
|
|
26
|
-
}
|
|
27
|
-
return ar;
|
|
28
|
-
};
|
|
29
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
30
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
31
|
-
if (ar || !(i in from)) {
|
|
32
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
33
|
-
ar[i] = from[i];
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
37
|
-
};
|
|
38
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
4
|
};
|
|
41
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
var e_1, _a;
|
|
49
|
-
var text = [];
|
|
50
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
51
|
-
text[_i - 1] = arguments[_i];
|
|
6
|
+
exports.toPascalCase = exports.toCamelCase = exports.splitWords = exports.deepMerge = exports.zodEnumFromObjKeys = exports.indent = exports.strConcat = exports.setOrPush = void 0;
|
|
7
|
+
const zod_1 = __importDefault(require("zod"));
|
|
8
|
+
/** @internal */
|
|
9
|
+
function setOrPush(newValue, currentValue, isArray) {
|
|
10
|
+
if (isArray) {
|
|
11
|
+
return [...(currentValue ?? []), newValue];
|
|
52
12
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
13
|
+
return newValue;
|
|
14
|
+
}
|
|
15
|
+
exports.setOrPush = setOrPush;
|
|
16
|
+
/**
|
|
17
|
+
* Concatenates strings, arrays of strings, and objects with truthy values.
|
|
18
|
+
*
|
|
19
|
+
* It works recursively, so adding an array of strings to an array of strings will work.
|
|
20
|
+
*
|
|
21
|
+
* Falsy values are ignored, so pasing `undefined` or `null` will not add anything to the result,
|
|
22
|
+
* and using a boolean will only add it if it is `true`. Using 0 will also not add anything.
|
|
23
|
+
*/
|
|
24
|
+
function strConcat(...strs) {
|
|
25
|
+
const res = [];
|
|
26
|
+
for (const str of strs) {
|
|
27
|
+
if (typeof str === 'string') {
|
|
28
|
+
res.push(str);
|
|
29
|
+
continue;
|
|
58
30
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
31
|
+
if (Array.isArray(str)) {
|
|
32
|
+
res.push(strConcat(...str));
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (str == null) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (typeof str === 'object') {
|
|
39
|
+
for (const [key, value] of Object.entries(str)) {
|
|
40
|
+
if (Boolean(value)) {
|
|
41
|
+
res.push(key);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (Boolean(str)) {
|
|
47
|
+
res.push(str.toString());
|
|
48
|
+
continue;
|
|
64
49
|
}
|
|
65
|
-
finally { if (e_1) throw e_1.error; }
|
|
66
50
|
}
|
|
67
|
-
return
|
|
51
|
+
return res.join('\n');
|
|
68
52
|
}
|
|
69
|
-
exports.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
53
|
+
exports.strConcat = strConcat;
|
|
54
|
+
/**
|
|
55
|
+
* Indents a string or an array of strings. Concatenates them all using `strConcat`.
|
|
56
|
+
*/
|
|
57
|
+
function indent(str, indent = 2) {
|
|
58
|
+
return strConcat(str)
|
|
59
|
+
.split('\n')
|
|
60
|
+
.map((s) => ' '.repeat(indent) + s)
|
|
61
|
+
.join('\n');
|
|
76
62
|
}
|
|
77
|
-
exports.
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
indent: 0,
|
|
83
|
-
colorCount: 0,
|
|
84
|
-
}, options);
|
|
85
|
-
var indentSize = (_a = _opts.indent) !== null && _a !== void 0 ? _a : 0;
|
|
86
|
-
var firstIndentSize = (_b = _opts.firstLineIndent) !== null && _b !== void 0 ? _b : indentSize;
|
|
87
|
-
var maxLineLength = _opts.printWidth - firstIndentSize + exports.COLOR_CODE_LEN * _opts.colorCount;
|
|
88
|
-
function indent(i, l) {
|
|
89
|
-
return (0, repeat_1.default)(" ", i === 0 ? firstIndentSize : indentSize) + l;
|
|
90
|
-
}
|
|
91
|
-
if (!_opts.printWidth || maxLineLength <= 0) {
|
|
92
|
-
return text.split("\n").map(function (l, i) { return indent(i, l); });
|
|
93
|
-
}
|
|
94
|
-
var lines = chunk(text, maxLineLength).map(function (l, i) { return indent(i, l); });
|
|
95
|
-
lines = __spreadArray([
|
|
96
|
-
lines[0]
|
|
97
|
-
], __read(chunk(lines
|
|
98
|
-
.slice(1)
|
|
99
|
-
.map(function (l) { return l.trim(); })
|
|
100
|
-
.join(" ")
|
|
101
|
-
.trim(), maxLineLength - indentSize - exports.COLOR_CODE_LEN).map(function (l, i) { return indent(i + 1, l); })), false).filter(function (l) { return l.trim().length; });
|
|
102
|
-
return lines;
|
|
63
|
+
exports.indent = indent;
|
|
64
|
+
/** @internal */
|
|
65
|
+
function zodEnumFromObjKeys(obj) {
|
|
66
|
+
const [firstKey, ...otherKeys] = Object.keys(obj);
|
|
67
|
+
return zod_1.default.enum([firstKey, ...otherKeys]);
|
|
103
68
|
}
|
|
104
|
-
exports.
|
|
105
|
-
|
|
106
|
-
function
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
69
|
+
exports.zodEnumFromObjKeys = zodEnumFromObjKeys;
|
|
70
|
+
/** @internal */
|
|
71
|
+
function deepMerge(obj1, obj2) {
|
|
72
|
+
const res = { ...obj1 };
|
|
73
|
+
if (obj1 == null)
|
|
74
|
+
return obj2;
|
|
75
|
+
if (obj2 == null)
|
|
76
|
+
return obj1;
|
|
77
|
+
for (const [key, value] of Object.entries(obj2)) {
|
|
78
|
+
if (typeof value === 'object' && typeof res[key] === 'object') {
|
|
79
|
+
res[key] = deepMerge(res[key], value);
|
|
114
80
|
}
|
|
115
81
|
else {
|
|
116
|
-
|
|
117
|
-
subStr = word;
|
|
82
|
+
res[key] = value;
|
|
118
83
|
}
|
|
119
84
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
85
|
+
return res;
|
|
86
|
+
}
|
|
87
|
+
exports.deepMerge = deepMerge;
|
|
88
|
+
/**
|
|
89
|
+
* Splits a name into words, using camelCase, PascalCase, snake_case, and kebab-case or
|
|
90
|
+
* regular spaced strings.
|
|
91
|
+
*/
|
|
92
|
+
function splitWords(str) {
|
|
93
|
+
return str
|
|
94
|
+
.replace(/([a-z])([A-Z])/g, '$1 $2')
|
|
95
|
+
.replace(/([a-zA-Z])([0-9])/g, '$1 $2')
|
|
96
|
+
.replace(/([0-9])([a-zA-Z])/g, '$1 $2')
|
|
97
|
+
.replace(/([a-z])([_-])/g, '$1 $2')
|
|
98
|
+
.replace(/([_-])([a-zA-Z])/g, '$1 $2')
|
|
99
|
+
.split(/[_-]/)
|
|
100
|
+
.map((s) => s.trim())
|
|
101
|
+
.filter(Boolean);
|
|
102
|
+
}
|
|
103
|
+
exports.splitWords = splitWords;
|
|
104
|
+
function toCamelCase(str) {
|
|
105
|
+
return splitWords(str)
|
|
106
|
+
.map((s, i) => (i === 0 ? s : s[0].toUpperCase() + s.slice(1)))
|
|
107
|
+
.join('');
|
|
124
108
|
}
|
|
125
|
-
|
|
126
|
-
|
|
109
|
+
exports.toCamelCase = toCamelCase;
|
|
110
|
+
function toPascalCase(str) {
|
|
111
|
+
return splitWords(str)
|
|
112
|
+
.map((s) => s[0].toUpperCase() + s.slice(1))
|
|
113
|
+
.join('');
|
|
127
114
|
}
|
|
128
|
-
exports.
|
|
115
|
+
exports.toPascalCase = toPascalCase;
|
|
129
116
|
//# sourceMappingURL=utils.js.map
|
package/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAmB;AAEnB,gBAAgB;AAChB,SAAgB,SAAS,CACvB,QAAiB,EACjB,YAAiC,EACjC,OAAgB;IAEhB,IAAI,OAAO,EAAE;QACX,OAAO,CAAC,GAAG,CAAE,YAA0B,IAAI,EAAE,CAAC,EAAE,QAAQ,CAAM,CAAA;KA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AAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SACpB,MAAM,CAAC,OAAO,CAAC,CAAA;AACpB,CAAC;AAVD,gCAUC;AAED,SAAgB,WAAW,CAAC,GAAW;IACrC,OAAO,UAAU,CAAC,GAAG,CAAC;SACnB,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SAC9D,IAAI,CAAC,EAAE,CAAC,CAAA;AACb,CAAC;AAJD,kCAIC;AAED,SAAgB,YAAY,CAAC,GAAW;IACtC,OAAO,UAAU,CAAC,GAAG,CAAC;SACnB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SAC3C,IAAI,CAAC,EAAE,CAAC,CAAA;AACb,CAAC;AAJD,oCAIC"}
|
package/assertions.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { CommandDef, ExampleDef, HelpDef, MainDef, OptionDef } from "./types";
|
|
2
|
-
export declare const colorList: string[];
|
|
3
|
-
export declare function assertHelp(help: HelpDef): void;
|
|
4
|
-
export declare function assertCommand(command: CommandDef<any>, allCommands: CommandDef<any>[]): void;
|
|
5
|
-
export declare function assertOption(option: OptionDef<any, any>, allOptions: OptionDef<any, any>[]): void;
|
|
6
|
-
export declare function assertExample(example: ExampleDef): void;
|
|
7
|
-
export declare function assertMain(run: MainDef<any>): void;
|
|
8
|
-
//# sourceMappingURL=assertions.d.ts.map
|
package/assertions.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assertions.d.ts","sourceRoot":"","sources":["../src/assertions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAS,SAAS,EAAE,MAAM,SAAS,CAAA;AAIpF,eAAO,MAAM,SAAS,UAIrB,CAAA;AAqED,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,QAkBvC;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,UAAU,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,CAI5F;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,UAAU,EAAE,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,IAAI,CAMjG;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,UAAU,QAIhD;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,QAE3C"}
|
package/assertions.js
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
18
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
19
|
-
if (!m) return o;
|
|
20
|
-
var i = m.call(o), r, ar = [], e;
|
|
21
|
-
try {
|
|
22
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
23
|
-
}
|
|
24
|
-
catch (error) { e = { error: error }; }
|
|
25
|
-
finally {
|
|
26
|
-
try {
|
|
27
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
28
|
-
}
|
|
29
|
-
finally { if (e) throw e.error; }
|
|
30
|
-
}
|
|
31
|
-
return ar;
|
|
32
|
-
};
|
|
33
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
34
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
35
|
-
if (ar || !(i in from)) {
|
|
36
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
37
|
-
ar[i] = from[i];
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
41
|
-
};
|
|
42
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
-
exports.assertMain = exports.assertExample = exports.assertOption = exports.assertCommand = exports.assertHelp = exports.colorList = void 0;
|
|
44
|
-
var utils_1 = require("./utils");
|
|
45
|
-
// prettier-ignore
|
|
46
|
-
exports.colorList = [
|
|
47
|
-
"reset", "bold", "dim", "italic", "underline", "inverse", "hidden", "strikethrough", "black", "red", "green",
|
|
48
|
-
"yellow", "blue", "magenta", "cyan", "white", "gray", "bgBlack", "bgRed", "bgGreen", "bgYellow", "bgBlue",
|
|
49
|
-
"bgMagenta", "bgCyan", "bgWhite",
|
|
50
|
-
];
|
|
51
|
-
var AssertionError = /** @class */ (function (_super) {
|
|
52
|
-
__extends(AssertionError, _super);
|
|
53
|
-
function AssertionError() {
|
|
54
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
55
|
-
}
|
|
56
|
-
return AssertionError;
|
|
57
|
-
}(Error));
|
|
58
|
-
function assert(condition, message) {
|
|
59
|
-
if (!condition) {
|
|
60
|
-
throw new AssertionError(message);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
function nullOr(condition, condition2) {
|
|
64
|
-
return [null, undefined].includes(condition) || condition2;
|
|
65
|
-
}
|
|
66
|
-
function assertRequired(obj, prefix, name) {
|
|
67
|
-
assert(![undefined, null].includes(obj), "".concat(prefix, ": ").concat(name, " must be provided"));
|
|
68
|
-
}
|
|
69
|
-
function assertType(obj, prefix, name, options) {
|
|
70
|
-
if (options.required) {
|
|
71
|
-
assertRequired(obj, prefix, name);
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
try {
|
|
75
|
-
assertRequired(obj, prefix, name);
|
|
76
|
-
}
|
|
77
|
-
catch (e) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
assert(typeof obj === options.type, "".concat(prefix, ": ").concat(name, " must be ").concat(options.type));
|
|
82
|
-
}
|
|
83
|
-
function assertNumber(obj, prefix, name, options) {
|
|
84
|
-
assertType(obj, prefix, name, { required: options.required, type: "number" });
|
|
85
|
-
if (!options.required && [null, undefined].includes(obj)) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
if (typeof options.max === "number") {
|
|
89
|
-
assert(obj <= options.max, "".concat(prefix, ": ").concat(name, " must be \u2264 ").concat(options.max));
|
|
90
|
-
}
|
|
91
|
-
if (typeof options.min === "number") {
|
|
92
|
-
assert(obj >= options.min, "".concat(prefix, ": ").concat(name, " must be \u2265 ").concat(options.min));
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
function assertColor(color, prefix, name) {
|
|
96
|
-
assert(nullOr(color, (0, utils_1.asArray)(color).every(function (c) { return exports.colorList.includes(c); })), "".concat(prefix, ": ").concat(name, " must be string or array of strings. Accepted values: ") + exports.colorList.join(", "));
|
|
97
|
-
}
|
|
98
|
-
function assertAliases(def, allDefs, prefix) {
|
|
99
|
-
assert(!def.aliases || def.aliases.every(function (a) { return !allDefs.find(function (opt) { var _a; return __spreadArray([opt.name], __read(((_a = opt.aliases) !== null && _a !== void 0 ? _a : [])), false).includes(a); }); }), "".concat(prefix, ": Aliases must be unique"));
|
|
100
|
-
}
|
|
101
|
-
function assertHelp(help) {
|
|
102
|
-
assertType(help.binName, "Help", "Binary Name", { type: "string" });
|
|
103
|
-
assertColor(help.normalColors, "Help", "Normal colors");
|
|
104
|
-
assertColor(help.bodyColors, "Help", "Body colors");
|
|
105
|
-
assertColor(help.titleColors, "Help", "Title colors");
|
|
106
|
-
assertColor(help.subtitleColors, "Help", "Subtitle colors");
|
|
107
|
-
assertColor(help.highlightColors, "Help", "Highlight colors");
|
|
108
|
-
assertType(help.footer, "Help", "Footer", { type: "string" });
|
|
109
|
-
assertType(help.header, "Help", "Header", { type: "string" });
|
|
110
|
-
assertType(help.optionNameSeparator, "Help", "Option Name Separator", { type: "string" });
|
|
111
|
-
assertType(help.commandNameSeparator, "Help", "Command Name Separator", { type: "string" });
|
|
112
|
-
assertNumber(help.printWidth, "Help", "Print Width", { min: 0 });
|
|
113
|
-
assertType(help.exampleInputPrefix, "Help", "Example Input Prefix", { type: "string" });
|
|
114
|
-
assertType(help.exampleOutputPrefix, "Help", "Example Output Prefix", { type: "string" });
|
|
115
|
-
assertType(help.usageExample, "Help", "Usage Example", { type: "string" });
|
|
116
|
-
assertType(help.useGlobalColumns, "Help", "Use Global Columns", { type: "boolean" });
|
|
117
|
-
assertType(help.includeDefaults, "Help", "Include Defaults", { type: "boolean" });
|
|
118
|
-
assertType(help.useColors, "Help", "Use Colors", { type: "boolean" });
|
|
119
|
-
}
|
|
120
|
-
exports.assertHelp = assertHelp;
|
|
121
|
-
function assertCommand(command, allCommands) {
|
|
122
|
-
assertType(command.name, "Command", "Name", { required: true, type: "string" });
|
|
123
|
-
assertAliases(command, allCommands, "Command");
|
|
124
|
-
assertType(command.run, "Command", "Run", { required: true, type: "function" });
|
|
125
|
-
}
|
|
126
|
-
exports.assertCommand = assertCommand;
|
|
127
|
-
function assertOption(option, allOptions) {
|
|
128
|
-
assert(option.name, "Option: Name must be provided");
|
|
129
|
-
assert(typeof option.name === "string", "Option: Name must be string");
|
|
130
|
-
assertAliases(option, allOptions, "Option");
|
|
131
|
-
assertType(option.boolean, "Option", "Default Value", { type: "boolean" });
|
|
132
|
-
assertType(option.parse, "Option", "Parse", { type: "function" });
|
|
133
|
-
}
|
|
134
|
-
exports.assertOption = assertOption;
|
|
135
|
-
function assertExample(example) {
|
|
136
|
-
assertType(example.input, "Example", "Input", { required: true, type: "string" });
|
|
137
|
-
assertType(example.output, "Example", "Output", { type: "string" });
|
|
138
|
-
assertType(example.description, "Example", "Description", { type: "string" });
|
|
139
|
-
}
|
|
140
|
-
exports.assertExample = assertExample;
|
|
141
|
-
function assertMain(run) {
|
|
142
|
-
assertType(run, "Main", "Main", { required: true, type: "function" });
|
|
143
|
-
}
|
|
144
|
-
exports.assertMain = assertMain;
|
|
145
|
-
//# sourceMappingURL=assertions.js.map
|