bob-core 3.0.0-beta.8 → 3.0.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/cjs/HelpFlag.d.ts +3 -3
- package/dist/cjs/args/index.d.ts +38 -17
- package/dist/cjs/flags/boolean.d.ts +4 -4
- package/dist/cjs/flags/custom.d.ts +1 -1
- package/dist/cjs/flags/directory.d.ts +9 -3
- package/dist/cjs/flags/file.d.ts +9 -3
- package/dist/cjs/flags/index.d.ts +42 -21
- package/dist/cjs/flags/number.d.ts +12 -3
- package/dist/cjs/flags/option.d.ts +26 -3
- package/dist/cjs/flags/string.d.ts +4 -4
- package/dist/cjs/flags/url.d.ts +4 -4
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/lib/types.d.ts +6 -6
- package/dist/cjs/shared/ask-helpers.d.ts +1 -1
- package/dist/cjs/shared/flagsUtils.d.ts +0 -2
- package/dist/esm/HelpFlag.d.ts +3 -3
- package/dist/esm/args/index.d.ts +38 -17
- package/dist/esm/flags/boolean.d.ts +4 -4
- package/dist/esm/flags/custom.d.ts +1 -1
- package/dist/esm/flags/directory.d.ts +9 -3
- package/dist/esm/flags/file.d.ts +9 -3
- package/dist/esm/flags/index.d.ts +42 -21
- package/dist/esm/flags/number.d.ts +12 -3
- package/dist/esm/flags/option.d.ts +26 -3
- package/dist/esm/flags/string.d.ts +4 -4
- package/dist/esm/flags/url.d.ts +4 -4
- package/dist/esm/index.js +3 -5
- package/dist/esm/lib/types.d.ts +6 -6
- package/dist/esm/shared/ask-helpers.d.ts +1 -1
- package/dist/esm/shared/flagsUtils.d.ts +0 -2
- package/package.json +1 -1
|
@@ -2,23 +2,32 @@
|
|
|
2
2
|
export declare const numberFlag: <const O extends Partial<import('../index.js').FlagDefinition<number, {
|
|
3
3
|
min?: number;
|
|
4
4
|
max?: number;
|
|
5
|
+
}>> = Partial<import('../index.js').FlagDefinition<number, {
|
|
6
|
+
min?: number;
|
|
7
|
+
max?: number;
|
|
5
8
|
}>>>(overrides?: O | undefined) => {
|
|
6
9
|
min?: number | undefined;
|
|
7
10
|
max?: number | undefined;
|
|
8
11
|
} & {
|
|
9
|
-
parse: (input: any, opts: import('../index.js').FlagOpts<
|
|
12
|
+
parse: (input: any, opts: import('../index.js').FlagOpts<number, {
|
|
10
13
|
min?: number;
|
|
11
14
|
max?: number;
|
|
12
15
|
}>) => number;
|
|
13
16
|
type?: import('../index.js').FlagKind;
|
|
14
|
-
ask?: (opts: import('../index.js').FlagOpts
|
|
17
|
+
ask?: ((opts: import('../index.js').FlagOpts<number, {
|
|
18
|
+
min?: number;
|
|
19
|
+
max?: number;
|
|
20
|
+
}>) => Promise<any>) | undefined;
|
|
15
21
|
description?: string;
|
|
16
22
|
required?: boolean;
|
|
17
23
|
default?: number | number[] | (() => number | number[] | null) | (() => Promise<number | number[] | null>) | null | undefined;
|
|
18
24
|
multiple?: boolean;
|
|
19
25
|
help?: string;
|
|
20
26
|
alias?: string | readonly string[];
|
|
21
|
-
handler?: ((value: number, opts: import('../index.js').FlagOpts
|
|
27
|
+
handler?: ((value: number, opts: import('../index.js').FlagOpts<number, {
|
|
28
|
+
min?: number;
|
|
29
|
+
max?: number;
|
|
30
|
+
}>) => {
|
|
22
31
|
shouldStop: boolean;
|
|
23
32
|
} | void) | undefined;
|
|
24
33
|
} & Partial<import('../index.js').FlagDefinition<number, {
|
|
@@ -1,8 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InitFlagDefinition } from '../lib/types.js';
|
|
2
2
|
export declare function optionFlag<const T extends readonly string[], const O extends Partial<InitFlagDefinition<T[number], {
|
|
3
3
|
options: T;
|
|
4
4
|
}>>>(opts: {
|
|
5
5
|
options: T;
|
|
6
|
-
} & O):
|
|
6
|
+
} & O): {
|
|
7
7
|
options: T;
|
|
8
|
-
}
|
|
8
|
+
} & {
|
|
9
|
+
parse: (input: any, opts: import('../lib/types.js').FlagOpts<T[number], {
|
|
10
|
+
options: T;
|
|
11
|
+
}>) => T[number];
|
|
12
|
+
type?: import('../lib/types.js').FlagKind;
|
|
13
|
+
ask?: ((opts: import('../lib/types.js').FlagOpts<T[number], {
|
|
14
|
+
options: T;
|
|
15
|
+
}>) => Promise<any>) | undefined;
|
|
16
|
+
description?: string;
|
|
17
|
+
required?: boolean;
|
|
18
|
+
default?: T[number] | T[number][] | (() => T[number] | T[number][] | null) | (() => Promise<T[number] | T[number][] | null>) | null | undefined;
|
|
19
|
+
multiple?: boolean;
|
|
20
|
+
help?: string;
|
|
21
|
+
alias?: string | readonly string[];
|
|
22
|
+
handler?: ((value: T[number], opts: import('../lib/types.js').FlagOpts<T[number], {
|
|
23
|
+
options: T;
|
|
24
|
+
}>) => {
|
|
25
|
+
shouldStop: boolean;
|
|
26
|
+
} | void) | undefined;
|
|
27
|
+
} & Partial<import('../lib/types.js').FlagDefinition<T[number], {
|
|
28
|
+
options: T;
|
|
29
|
+
}>> & {
|
|
30
|
+
options: T;
|
|
31
|
+
} & O;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/** Text input flag. Pass `secret: true` to mask the prompt as a password. */
|
|
2
|
-
export declare const stringFlag: <const O extends Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions>>>(overrides?: O | undefined) => {
|
|
2
|
+
export declare const stringFlag: <const O extends Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions>> = Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions>>>(overrides?: O | undefined) => {
|
|
3
3
|
[x: string]: unknown;
|
|
4
4
|
} & {
|
|
5
|
-
parse: (input: any, opts: import('../index.js').FlagOpts<
|
|
5
|
+
parse: (input: any, opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions>) => string;
|
|
6
6
|
type?: import('../index.js').FlagKind;
|
|
7
|
-
ask?: (opts: import('../index.js').FlagOpts) => Promise<any
|
|
7
|
+
ask?: ((opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions>) => Promise<any>) | undefined;
|
|
8
8
|
description?: string;
|
|
9
9
|
required?: boolean;
|
|
10
10
|
default?: string | string[] | (() => string | string[] | null) | (() => Promise<string | string[] | null>) | null | undefined;
|
|
11
11
|
multiple?: boolean;
|
|
12
12
|
help?: string;
|
|
13
13
|
alias?: string | readonly string[];
|
|
14
|
-
handler?: ((value: string, opts: import('../index.js').FlagOpts) => {
|
|
14
|
+
handler?: ((value: string, opts: import('../index.js').FlagOpts<string, import('../index.js').CustomOptions>) => {
|
|
15
15
|
shouldStop: boolean;
|
|
16
16
|
} | void) | undefined;
|
|
17
17
|
} & Partial<import('../index.js').FlagDefinition<string, import('../index.js').CustomOptions>> & O;
|
package/dist/esm/flags/url.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/** URL flag — parses the input with `new URL()` and returns the resulting `URL` object. */
|
|
2
|
-
export declare const urlFlag: <const O extends Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions>>>(overrides?: O | undefined) => {
|
|
2
|
+
export declare const urlFlag: <const O extends Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions>> = Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions>>>(overrides?: O | undefined) => {
|
|
3
3
|
[x: string]: unknown;
|
|
4
4
|
} & {
|
|
5
|
-
parse: (input: any, opts: import('../index.js').FlagOpts<
|
|
5
|
+
parse: (input: any, opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions>) => URL;
|
|
6
6
|
type?: import('../index.js').FlagKind;
|
|
7
|
-
ask?: (opts: import('../index.js').FlagOpts) => Promise<any
|
|
7
|
+
ask?: ((opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions>) => Promise<any>) | undefined;
|
|
8
8
|
description?: string;
|
|
9
9
|
required?: boolean;
|
|
10
10
|
default?: URL | URL[] | (() => URL | URL[] | null) | (() => Promise<URL | URL[] | null>) | null | undefined;
|
|
11
11
|
multiple?: boolean;
|
|
12
12
|
help?: string;
|
|
13
13
|
alias?: string | readonly string[];
|
|
14
|
-
handler?: ((value: URL, opts: import('../index.js').FlagOpts) => {
|
|
14
|
+
handler?: ((value: URL, opts: import('../index.js').FlagOpts<URL, import('../index.js').CustomOptions>) => {
|
|
15
15
|
shouldStop: boolean;
|
|
16
16
|
} | void) | undefined;
|
|
17
17
|
} & Partial<import('../index.js').FlagDefinition<URL, import('../index.js').CustomOptions>> & O;
|
package/dist/esm/index.js
CHANGED
|
@@ -536,13 +536,11 @@ var F = M({
|
|
|
536
536
|
//#endregion
|
|
537
537
|
//#region src/flags/option.ts
|
|
538
538
|
function R(e) {
|
|
539
|
-
let { options: t, ...n } = e;
|
|
540
539
|
return M({
|
|
541
540
|
type: "option",
|
|
542
541
|
ask: Ee,
|
|
543
|
-
parse: (
|
|
544
|
-
|
|
545
|
-
})(n);
|
|
542
|
+
parse: (t) => ye(t, e.options ?? [])
|
|
543
|
+
})(e);
|
|
546
544
|
}
|
|
547
545
|
//#endregion
|
|
548
546
|
//#region src/flags/string.ts
|
|
@@ -1160,7 +1158,7 @@ var Ke = .75, qe = .55, Je = .05, Ye = class {
|
|
|
1160
1158
|
}, Ze = /* @__PURE__ */ ue(Ne(), 1);
|
|
1161
1159
|
function Qe() {
|
|
1162
1160
|
try {
|
|
1163
|
-
let e = n((0, Ze.fileURLToPath)(new URL("data:application/json;base64,
|
|
1161
|
+
let e = n((0, Ze.fileURLToPath)(new URL("data:application/json;base64,ewogICJuYW1lIjogImJvYi1jb3JlIiwKICAidmVyc2lvbiI6ICIzLjAuMCIsCiAgImRlc2NyaXB0aW9uIjogIkJPQiBDb3JlIiwKICAidHlwZSI6ICJtb2R1bGUiLAogICJtYWluIjogIi4vZGlzdC9janMvaW5kZXguanMiLAogICJtb2R1bGUiOiAiLi9kaXN0L2VzbS9pbmRleC5qcyIsCiAgInR5cGVzIjogIi4vZGlzdC9lc20vaW5kZXguZC50cyIsCiAgImZpbGVzIjogWwogICAgImRpc3QiCiAgXSwKICAiZXhwb3J0cyI6IHsKICAgICIuIjogewogICAgICAiaW1wb3J0IjogewogICAgICAgICJ0eXBlcyI6ICIuL2Rpc3QvZXNtL2luZGV4LmQudHMiLAogICAgICAgICJkZWZhdWx0IjogIi4vZGlzdC9lc20vaW5kZXguanMiCiAgICAgIH0sCiAgICAgICJyZXF1aXJlIjogewogICAgICAgICJ0eXBlcyI6ICIuL2Rpc3QvY2pzL2luZGV4LmQudHMiLAogICAgICAgICJkZWZhdWx0IjogIi4vZGlzdC9janMvaW5kZXguanMiCiAgICAgIH0KICAgIH0KICB9LAogICJzY3JpcHRzIjogewogICAgInN0YXJ0IjogIm5vZGUgLXIgQHN3Yy1ub2RlL3JlZ2lzdGVyIGRlYnVnL21haW4udHMiLAogICAgImJ1aWxkIjogInJtIC1yZiAuL2Rpc3QgJiYgdml0ZSBidWlsZCIsCiAgICAidHlwZWNoZWNrIjogInRzYyAtLW5vRW1pdCIsCiAgICAicHJlcGFjayI6ICJucG0gcnVuIGJ1aWxkIiwKICAgICJ0ZXN0IjogInZpdGVzdCBydW4iLAogICAgImxpbnQiOiAiZXNsaW50IC4iLAogICAgImxpbnQ6Zml4IjogImVzbGludCAuIC0tZml4IgogIH0sCiAgImF1dGhvciI6ICJMw6lvIEh1YmVydCIsCiAgImxpY2Vuc2UiOiAiSVNDIiwKICAiZGV2RGVwZW5kZW5jaWVzIjogewogICAgIkBlc2xpbnQvanMiOiAiXjkuMzkuNCIsCiAgICAiQGZha2VyLWpzL2Zha2VyIjogIl4xMC4zLjAiLAogICAgIkBzd2Mtbm9kZS9yZWdpc3RlciI6ICJeMS4xMS4xIiwKICAgICJAdHJpdmFnby9wcmV0dGllci1wbHVnaW4tc29ydC1pbXBvcnRzIjogIl41LjIuMiIsCiAgICAiQHR5cGVzL21pbmltaXN0IjogIl4xLjIuNSIsCiAgICAiQHR5cGVzL25vZGUiOiAiXjIwLjE0LjUiLAogICAgIkB0eXBlcy9zdHJpbmctc2ltaWxhcml0eSI6ICJeNC4wLjIiLAogICAgIkB2aXRlc3QvY292ZXJhZ2UtdjgiOiAiXjQuMS4wIiwKICAgICJlc2xpbnQiOiAiXjkuMzkuNCIsCiAgICAiZXNsaW50LWNvbmZpZy1wcmV0dGllciI6ICJeMTAuMS44IiwKICAgICJlc2xpbnQtcGx1Z2luLXByZXR0aWVyIjogIl41LjUuNSIsCiAgICAicHJldHRpZXIiOiAiXjMuNi4yIiwKICAgICJ0c3giOiAiXjQuMjEuMCIsCiAgICAidHlwZXNjcmlwdCI6ICJeNS45LjMiLAogICAgInR5cGVzY3JpcHQtZXNsaW50IjogIl44LjU3LjAiLAogICAgInZpdGUiOiAiXjguMC4wIiwKICAgICJ2aXRlLXBsdWdpbi1kdHMiOiAiXjQuNS40IiwKICAgICJ2aXRlc3QiOiAiXjQuMS4wIgogIH0sCiAgImRlcGVuZGVuY2llcyI6IHsKICAgICJAaW5xdWlyZXIvY29yZSI6ICJeMTEuMS44IiwKICAgICJAaW5xdWlyZXIvcHJvbXB0cyI6ICJeOC40LjEiLAogICAgImNoYWxrIjogIl41LjYuMiIsCiAgICAiaW5xdWlyZXItZmlsZS1zZWxlY3RvciI6ICJeMS4wLjEiLAogICAgIm1pbmltaXN0IjogIl4xLjIuOCIKICB9Cn0K", "" + import.meta.url)), "utf8");
|
|
1164
1162
|
return JSON.parse(e).version ?? "0.0.0";
|
|
1165
1163
|
} catch {
|
|
1166
1164
|
return "0.0.0";
|
package/dist/esm/lib/types.d.ts
CHANGED
|
@@ -11,26 +11,26 @@ export type FlagKind = 'string' | 'number' | 'boolean' | 'option' | 'file' | 'di
|
|
|
11
11
|
* {@link FlagDefinition}, so handlers can read them without `any` casts while still
|
|
12
12
|
* being honest that they are optional at the type level.
|
|
13
13
|
*/
|
|
14
|
-
export type FlagOpts<
|
|
14
|
+
export type FlagOpts<T = any, C extends CustomOptions = CustomOptions> = {
|
|
15
15
|
name: string;
|
|
16
16
|
ux: UX;
|
|
17
|
-
ctx:
|
|
18
|
-
definition: FlagDefinition<
|
|
17
|
+
ctx: ContextDefinition;
|
|
18
|
+
definition: FlagDefinition<T, C>;
|
|
19
19
|
cmd: typeof Command;
|
|
20
20
|
};
|
|
21
21
|
export type FlagDefinition<T = any, C extends CustomOptions = CustomOptions> = {
|
|
22
22
|
[key in keyof C]: C[keyof C];
|
|
23
23
|
} & {
|
|
24
|
-
parse: (input: any, opts: FlagOpts<
|
|
24
|
+
parse: (input: any, opts: FlagOpts<T, C>) => T;
|
|
25
25
|
type?: FlagKind;
|
|
26
|
-
ask?: (opts: FlagOpts) => Promise<any>;
|
|
26
|
+
ask?: (opts: FlagOpts<T, C>) => Promise<any>;
|
|
27
27
|
description?: string;
|
|
28
28
|
required?: boolean;
|
|
29
29
|
default?: T | T[] | null | (() => T | T[] | null) | (() => Promise<T | T[] | null>);
|
|
30
30
|
multiple?: boolean;
|
|
31
31
|
help?: string;
|
|
32
32
|
alias?: string | readonly string[];
|
|
33
|
-
handler?: (value: T, opts: FlagOpts) => {
|
|
33
|
+
handler?: (value: T, opts: FlagOpts<T, C>) => {
|
|
34
34
|
shouldStop: boolean;
|
|
35
35
|
} | void;
|
|
36
36
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FlagOpts } from '../lib/types.js';
|
|
2
2
|
export declare function buildStringAsk(builderOpts: FlagOpts): Promise<any>;
|
|
3
3
|
export declare function buildNumberAsk(builderOpts: FlagOpts): Promise<any>;
|
|
4
|
-
export declare function buildOptionAsk(builderOpts: FlagOpts): Promise<any>;
|
|
4
|
+
export declare function buildOptionAsk(builderOpts: FlagOpts<any, any>): Promise<any>;
|
|
5
5
|
export declare function buildFileAsk(builderOpts: FlagOpts): Promise<any>;
|
|
6
6
|
export declare function buildDirectoryAsk(builderOpts: FlagOpts): Promise<any>;
|
|
7
7
|
export declare function buildUrlAsk(builderOpts: FlagOpts): Promise<any>;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { numberFlag } from '../flags/number.js';
|
|
2
1
|
import { optionFlag } from '../flags/option.js';
|
|
3
2
|
import { FlagDefinition } from '../lib/types.js';
|
|
4
|
-
export declare function isNumberFlag(flag: FlagDefinition): flag is ReturnType<typeof numberFlag>;
|
|
5
3
|
export declare function isOptionFlag(flag: FlagDefinition<any, any>): flag is ReturnType<typeof optionFlag>;
|