@boneskull/bargs 0.1.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/LICENSE +55 -0
- package/README.md +483 -0
- package/dist/bargs.cjs +167 -0
- package/dist/bargs.cjs.map +1 -0
- package/dist/bargs.d.cts +31 -0
- package/dist/bargs.d.cts.map +1 -0
- package/dist/bargs.d.ts +31 -0
- package/dist/bargs.d.ts.map +1 -0
- package/dist/bargs.js +163 -0
- package/dist/bargs.js.map +1 -0
- package/dist/errors.cjs +57 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.cts +40 -0
- package/dist/errors.d.cts.map +1 -0
- package/dist/errors.d.ts +40 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +51 -0
- package/dist/errors.js.map +1 -0
- package/dist/help.cjs +309 -0
- package/dist/help.cjs.map +1 -0
- package/dist/help.d.cts +21 -0
- package/dist/help.d.cts.map +1 -0
- package/dist/help.d.ts +21 -0
- package/dist/help.d.ts.map +1 -0
- package/dist/help.js +304 -0
- package/dist/help.js.map +1 -0
- package/dist/index.cjs +63 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +96 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +96 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -0
- package/dist/opt.cjs +205 -0
- package/dist/opt.cjs.map +1 -0
- package/dist/opt.d.cts +145 -0
- package/dist/opt.d.cts.map +1 -0
- package/dist/opt.d.ts +145 -0
- package/dist/opt.d.ts.map +1 -0
- package/dist/opt.js +202 -0
- package/dist/opt.js.map +1 -0
- package/dist/osc.cjs +190 -0
- package/dist/osc.cjs.map +1 -0
- package/dist/osc.d.cts +30 -0
- package/dist/osc.d.cts.map +1 -0
- package/dist/osc.d.ts +30 -0
- package/dist/osc.d.ts.map +1 -0
- package/dist/osc.js +181 -0
- package/dist/osc.js.map +1 -0
- package/dist/parser.cjs +293 -0
- package/dist/parser.cjs.map +1 -0
- package/dist/parser.d.cts +47 -0
- package/dist/parser.d.cts.map +1 -0
- package/dist/parser.d.ts +47 -0
- package/dist/parser.d.ts.map +1 -0
- package/dist/parser.js +285 -0
- package/dist/parser.js.map +1 -0
- package/dist/theme.cjs +203 -0
- package/dist/theme.cjs.map +1 -0
- package/dist/theme.d.cts +227 -0
- package/dist/theme.d.cts.map +1 -0
- package/dist/theme.d.ts +227 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +198 -0
- package/dist/theme.js.map +1 -0
- package/dist/types.cjs +18 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +244 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.ts +244 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +17 -0
- package/dist/types.js.map +1 -0
- package/dist/validate.cjs +452 -0
- package/dist/validate.cjs.map +1 -0
- package/dist/validate.d.cts +28 -0
- package/dist/validate.d.cts.map +1 -0
- package/dist/validate.d.ts +28 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +448 -0
- package/dist/validate.js.map +1 -0
- package/dist/version.cjs +134 -0
- package/dist/version.cjs.map +1 -0
- package/dist/version.d.cts +27 -0
- package/dist/version.d.cts.map +1 -0
- package/dist/version.d.ts +27 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +129 -0
- package/dist/version.js.map +1 -0
- package/package.json +149 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bargs.js","sourceRoot":"","sources":["../src/bargs.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;AAkLH,sBAuCC;AAgCD,gCAuCC;AAlRD,4CAAwC;AACxC,wCAA8D;AAC9D,4CAMqB;AACrB,0CAAgE;AAChE,gDAA+C;AAE/C;;GAEG;AACH,MAAM,WAAW,GAAG,CAClB,MAIC,EAID,EAAE,CAAC,MAAM,CAAC,QAAQ,KAAK,SAAS,IAAI,MAAM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AAC;YAC5C,CAAC;YAED,OAAO,MAAM,CAAC;QAChB,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC"}
|
package/dist/bargs.d.cts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core bargs parsing functions for both sync and async CLI execution.
|
|
3
|
+
*
|
|
4
|
+
* Provides `bargs()` (synchronous) and `bargsAsync()` (asynchronous) entry
|
|
5
|
+
* points that handle configuration validation, built-in `--help` and
|
|
6
|
+
* `--version` flags, argument parsing, and handler invocation. Supports both
|
|
7
|
+
* simple CLIs with options/positionals and command-based CLIs with
|
|
8
|
+
* subcommands.
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
import type { BargsConfig, BargsConfigWithCommands, BargsOptions, BargsResult, CommandConfigInput, InferOptions, InferPositionals, OptionsSchema, PositionalsSchema } from "./types.cjs";
|
|
13
|
+
/**
|
|
14
|
+
* Main bargs entry point for simple CLIs (no commands) - sync version. Throws
|
|
15
|
+
* if any handler returns a thenable.
|
|
16
|
+
*/
|
|
17
|
+
export declare function bargs<TOptions extends OptionsSchema, TPositionals extends PositionalsSchema>(config: BargsConfig<TOptions, TPositionals, undefined>, options?: BargsOptions): BargsResult<InferOptions<TOptions>, InferPositionals<TPositionals>, undefined>;
|
|
18
|
+
/**
|
|
19
|
+
* Main bargs entry point for command-based CLIs - sync version. Throws if any
|
|
20
|
+
* handler returns a thenable.
|
|
21
|
+
*/
|
|
22
|
+
export declare function bargs<TOptions extends OptionsSchema, TCommands extends Record<string, CommandConfigInput>>(config: BargsConfigWithCommands<TOptions, TCommands>, options?: BargsOptions): BargsResult<InferOptions<TOptions>, unknown[], string | undefined>;
|
|
23
|
+
/**
|
|
24
|
+
* Main bargs entry point for simple CLIs (no commands) - async version.
|
|
25
|
+
*/
|
|
26
|
+
export declare function bargsAsync<TOptions extends OptionsSchema, TPositionals extends PositionalsSchema>(config: BargsConfig<TOptions, TPositionals, undefined>, options?: BargsOptions): Promise<BargsResult<InferOptions<TOptions>, InferPositionals<TPositionals>, undefined>>;
|
|
27
|
+
/**
|
|
28
|
+
* Main bargs entry point for command-based CLIs - async version.
|
|
29
|
+
*/
|
|
30
|
+
export declare function bargsAsync<TOptions extends OptionsSchema, TCommands extends Record<string, CommandConfigInput>>(config: BargsConfigWithCommands<TOptions, TCommands>, options?: BargsOptions): Promise<BargsResult<InferOptions<TOptions>, unknown[], string | undefined>>;
|
|
31
|
+
//# sourceMappingURL=bargs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bargs.d.ts","sourceRoot":"","sources":["../src/bargs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,uBAAuB,EACvB,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EAClB,oBAAmB;AAsIpB;;;GAGG;AACH,wBAAgB,KAAK,CACnB,QAAQ,SAAS,aAAa,EAC9B,YAAY,SAAS,iBAAiB,EAEtC,MAAM,EAAE,WAAW,CAAC,QAAQ,EAAE,YAAY,EAAE,SAAS,CAAC,EACtD,OAAO,CAAC,EAAE,YAAY,GACrB,WAAW,CACZ,YAAY,CAAC,QAAQ,CAAC,EACtB,gBAAgB,CAAC,YAAY,CAAC,EAC9B,SAAS,CACV,CAAC;AAEF;;;GAGG;AACH,wBAAgB,KAAK,CACnB,QAAQ,SAAS,aAAa,EAC9B,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAEpD,MAAM,EAAE,uBAAuB,CAAC,QAAQ,EAAE,SAAS,CAAC,EACpD,OAAO,CAAC,EAAE,YAAY,GACrB,WAAW,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAiDtE;;GAEG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,SAAS,aAAa,EAC9B,YAAY,SAAS,iBAAiB,EAEtC,MAAM,EAAE,WAAW,CAAC,QAAQ,EAAE,YAAY,EAAE,SAAS,CAAC,EACtD,OAAO,CAAC,EAAE,YAAY,GACrB,OAAO,CACR,WAAW,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,gBAAgB,CAAC,YAAY,CAAC,EAAE,SAAS,CAAC,CAC/E,CAAC;AAEF;;GAEG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,SAAS,aAAa,EAC9B,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAEpD,MAAM,EAAE,uBAAuB,CAAC,QAAQ,EAAE,SAAS,CAAC,EACpD,OAAO,CAAC,EAAE,YAAY,GACrB,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC"}
|
package/dist/bargs.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core bargs parsing functions for both sync and async CLI execution.
|
|
3
|
+
*
|
|
4
|
+
* Provides `bargs()` (synchronous) and `bargsAsync()` (asynchronous) entry
|
|
5
|
+
* points that handle configuration validation, built-in `--help` and
|
|
6
|
+
* `--version` flags, argument parsing, and handler invocation. Supports both
|
|
7
|
+
* simple CLIs with options/positionals and command-based CLIs with
|
|
8
|
+
* subcommands.
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
import type { BargsConfig, BargsConfigWithCommands, BargsOptions, BargsResult, CommandConfigInput, InferOptions, InferPositionals, OptionsSchema, PositionalsSchema } from "./types.js";
|
|
13
|
+
/**
|
|
14
|
+
* Main bargs entry point for simple CLIs (no commands) - sync version. Throws
|
|
15
|
+
* if any handler returns a thenable.
|
|
16
|
+
*/
|
|
17
|
+
export declare function bargs<TOptions extends OptionsSchema, TPositionals extends PositionalsSchema>(config: BargsConfig<TOptions, TPositionals, undefined>, options?: BargsOptions): BargsResult<InferOptions<TOptions>, InferPositionals<TPositionals>, undefined>;
|
|
18
|
+
/**
|
|
19
|
+
* Main bargs entry point for command-based CLIs - sync version. Throws if any
|
|
20
|
+
* handler returns a thenable.
|
|
21
|
+
*/
|
|
22
|
+
export declare function bargs<TOptions extends OptionsSchema, TCommands extends Record<string, CommandConfigInput>>(config: BargsConfigWithCommands<TOptions, TCommands>, options?: BargsOptions): BargsResult<InferOptions<TOptions>, unknown[], string | undefined>;
|
|
23
|
+
/**
|
|
24
|
+
* Main bargs entry point for simple CLIs (no commands) - async version.
|
|
25
|
+
*/
|
|
26
|
+
export declare function bargsAsync<TOptions extends OptionsSchema, TPositionals extends PositionalsSchema>(config: BargsConfig<TOptions, TPositionals, undefined>, options?: BargsOptions): Promise<BargsResult<InferOptions<TOptions>, InferPositionals<TPositionals>, undefined>>;
|
|
27
|
+
/**
|
|
28
|
+
* Main bargs entry point for command-based CLIs - async version.
|
|
29
|
+
*/
|
|
30
|
+
export declare function bargsAsync<TOptions extends OptionsSchema, TCommands extends Record<string, CommandConfigInput>>(config: BargsConfigWithCommands<TOptions, TCommands>, options?: BargsOptions): Promise<BargsResult<InferOptions<TOptions>, unknown[], string | undefined>>;
|
|
31
|
+
//# sourceMappingURL=bargs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bargs.d.ts","sourceRoot":"","sources":["../src/bargs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,uBAAuB,EACvB,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EAClB,mBAAmB;AAsIpB;;;GAGG;AACH,wBAAgB,KAA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|
|
1
|
+
/**
|
|
2
|
+
* Core bargs parsing functions for both sync and async CLI execution.
|
|
3
|
+
*
|
|
4
|
+
* Provides `bargs()` (synchronous) and `bargsAsync()` (asynchronous) entry
|
|
5
|
+
* points that handle configuration validation, built-in `--help` and
|
|
6
|
+
* `--version` flags, argument parsing, and handler invocation. Supports both
|
|
7
|
+
* simple CLIs with options/positionals and command-based CLIs with
|
|
8
|
+
* subcommands.
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
import { HelpError } from "./errors.js";
|
|
13
|
+
import { generateCommandHelp, generateHelp } from "./help.js";
|
|
14
|
+
import { parseCommandsAsync, parseCommandsSync, parseSimple, runHandlers, runSyncHandlers, } from "./parser.js";
|
|
15
|
+
import { defaultTheme, getTheme } from "./theme.js";
|
|
16
|
+
import { validateConfig } from "./validate.js";
|
|
17
|
+
/**
|
|
18
|
+
* Check if config has commands.
|
|
19
|
+
*/
|
|
20
|
+
const hasCommands = (config) => config.commands !== undefined && Object.keys(config.commands).length > 0;
|
|
21
|
+
/**
|
|
22
|
+
* Check if user defined their own help option (by name or alias).
|
|
23
|
+
*/
|
|
24
|
+
const hasUserDefinedHelp = (options) => {
|
|
25
|
+
if (!options) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
if ('help' in options) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
// Check if any option has 'h' as an alias
|
|
32
|
+
return Object.values(options).some((opt) => opt.aliases?.includes('h'));
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Check if user defined their own version option (by name or alias).
|
|
36
|
+
*/
|
|
37
|
+
const hasUserDefinedVersion = (options) => {
|
|
38
|
+
if (!options) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
if ('version' in options) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
// Check if any option has 'V' as an alias
|
|
45
|
+
return Object.values(options).some((opt) => opt.aliases?.includes('V'));
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Handle help and version flags. Returns true if we should exit.
|
|
49
|
+
*/
|
|
50
|
+
const handleBuiltinFlags = (config, args, theme = defaultTheme) => {
|
|
51
|
+
// Handle --help (unless user defined their own help option)
|
|
52
|
+
const userDefinedHelp = hasUserDefinedHelp(config.options);
|
|
53
|
+
if (!userDefinedHelp && (args.includes('--help') || args.includes('-h'))) {
|
|
54
|
+
if (hasCommands(config)) {
|
|
55
|
+
// Check for command-specific help: cmd --help
|
|
56
|
+
const helpIndex = args.findIndex((a) => a === '--help' || a === '-h');
|
|
57
|
+
const commandIndex = args.findIndex((a) => !a.startsWith('-'));
|
|
58
|
+
if (commandIndex >= 0 && commandIndex < helpIndex) {
|
|
59
|
+
const commandName = args[commandIndex];
|
|
60
|
+
console.log(generateCommandHelp(config, commandName, theme));
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
console.log(generateHelp(config, theme));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
console.log(generateHelp(config, theme));
|
|
68
|
+
}
|
|
69
|
+
process.exit(0);
|
|
70
|
+
}
|
|
71
|
+
// Handle --version (unless user defined their own version option)
|
|
72
|
+
const userDefinedVersion = hasUserDefinedVersion(config.options);
|
|
73
|
+
if (!userDefinedVersion && args.includes('--version') && config.version) {
|
|
74
|
+
console.log(config.version);
|
|
75
|
+
process.exit(0);
|
|
76
|
+
}
|
|
77
|
+
return false;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Handle HelpError by printing message and help text.
|
|
81
|
+
*/
|
|
82
|
+
const handleHelpError = (error, config, theme = defaultTheme) => {
|
|
83
|
+
if (error instanceof HelpError) {
|
|
84
|
+
console.error(error.message);
|
|
85
|
+
if (hasCommands(config)) {
|
|
86
|
+
console.log(generateHelp(config, theme));
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
console.log(generateHelp(config, theme));
|
|
90
|
+
}
|
|
91
|
+
process.exit(1);
|
|
92
|
+
}
|
|
93
|
+
throw error;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Main bargs entry point (sync implementation). Throws BargsError if any
|
|
97
|
+
* handler returns a thenable.
|
|
98
|
+
*/
|
|
99
|
+
export function bargs(config, options) {
|
|
100
|
+
// Validate config upfront (throws ValidationError if invalid)
|
|
101
|
+
validateConfig(config);
|
|
102
|
+
const args = config.args ?? process.argv.slice(2);
|
|
103
|
+
const theme = options?.theme
|
|
104
|
+
? getTheme(options.theme)
|
|
105
|
+
: getTheme('default');
|
|
106
|
+
try {
|
|
107
|
+
handleBuiltinFlags(config, args, theme);
|
|
108
|
+
// Parse
|
|
109
|
+
if (hasCommands(config)) {
|
|
110
|
+
return parseCommandsSync({ ...config, args });
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
const result = parseSimple({
|
|
114
|
+
args,
|
|
115
|
+
options: config.options,
|
|
116
|
+
positionals: config.positionals,
|
|
117
|
+
});
|
|
118
|
+
// Call handler(s) if provided (sync)
|
|
119
|
+
if (config.handler) {
|
|
120
|
+
runSyncHandlers(config.handler, result);
|
|
121
|
+
}
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
return handleHelpError(error, config, theme);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Main bargs entry point (async implementation). Awaits all handlers,
|
|
131
|
+
* supporting async handlers.
|
|
132
|
+
*/
|
|
133
|
+
export async function bargsAsync(config, options) {
|
|
134
|
+
// Validate config upfront (throws ValidationError if invalid)
|
|
135
|
+
validateConfig(config);
|
|
136
|
+
const args = config.args ?? process.argv.slice(2);
|
|
137
|
+
const theme = options?.theme
|
|
138
|
+
? getTheme(options.theme)
|
|
139
|
+
: getTheme('default');
|
|
140
|
+
try {
|
|
141
|
+
handleBuiltinFlags(config, args, theme);
|
|
142
|
+
// Parse
|
|
143
|
+
if (hasCommands(config)) {
|
|
144
|
+
return await parseCommandsAsync({ ...config, args });
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
const result = parseSimple({
|
|
148
|
+
args,
|
|
149
|
+
options: config.options,
|
|
150
|
+
positionals: config.positionals,
|
|
151
|
+
});
|
|
152
|
+
// Call handler(s) if provided (async)
|
|
153
|
+
if (config.handler) {
|
|
154
|
+
await runHandlers(config.handler, result);
|
|
155
|
+
}
|
|
156
|
+
return result;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
return handleHelpError(error, config, theme);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=bargs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bargs.js","sourceRoot":"","sources":["../src/bargs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAcH,OAAO,EAAE,SAAS,EAAE,oBAAoB;AACxC,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,kBAAkB;AAC9D,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,eAAe,GAChB,oBAAoB;AACrB,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAc,mBAAmB;AAChE,OAAO,EAAE,cAAc,EAAE,sBAAsB;AAE/C;;GAEG;AACH,MAAM,WAAW,GAAG,CAClB,MAIC,EAID,EAAE,CAAC,MAAM,CAAC,QAAQ,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;AAE9E;;GAEG;AACH,MAAM,kBAAkB,GAAG,CAAC,OAAuB,EAAW,EAAE;IAC9D,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,MAAM,IAAI,OAAO,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IACD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AU,CAC9B,MAIC,EACD,OAAsB;IAEtB,8DAA8D;IAC9D,cAAc,CAAC,MAAM,CAAC,CAAC;IAEvB,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAClD,MAAM,KAAK,GAAU,OAAO,EAAE,KAAK;QACjC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC;QACzB,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAExB,IAAI,CAAC;QACH,kBAAkB,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QAExC,QAAQ;QACR,IAAI,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;YACxB,OAAO,MAAM,kBAAkB,CAAC,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QACvD,CAAC;aAAM,CAAC;YACN,MAAM,MAAM,GAAG,WAAW,CAAC;gBACzB,IAAI;gBACJ,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,WAAW,EAAE,MAAM,CAAC,WAAW;aAChC,CAAC,CAAC;YAEH,sCAAsC;YACtC,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACnB,MAAM,WAAW,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAC5C,CAAC;YAED,OAAO,MAAM,CAAC;QAChB,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC"}
|
package/dist/errors.cjs
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Custom error classes for bargs.
|
|
4
|
+
*
|
|
5
|
+
* Defines the error hierarchy used throughout bargs:
|
|
6
|
+
*
|
|
7
|
+
* - {@link BargsError} - Base class for all bargs errors
|
|
8
|
+
* - {@link HelpError} - Triggers help text display when user needs guidance
|
|
9
|
+
* - {@link ValidationError} - Thrown when configuration validation fails
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.ValidationError = exports.HelpError = exports.BargsError = void 0;
|
|
15
|
+
/**
|
|
16
|
+
* Custom error class for bargs errors.
|
|
17
|
+
*/
|
|
18
|
+
class BargsError extends Error {
|
|
19
|
+
constructor(message) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.name = 'BargsError';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.BargsError = BargsError;
|
|
25
|
+
/**
|
|
26
|
+
* Error that triggers help text display. Thrown when the user needs guidance.
|
|
27
|
+
*
|
|
28
|
+
* @param message - Error message to show before help text
|
|
29
|
+
* @param command - Command name for command-specific help, undefined for
|
|
30
|
+
* general help
|
|
31
|
+
*/
|
|
32
|
+
class HelpError extends BargsError {
|
|
33
|
+
command;
|
|
34
|
+
constructor(message, command) {
|
|
35
|
+
super(message);
|
|
36
|
+
this.name = 'HelpError';
|
|
37
|
+
this.command = command;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.HelpError = HelpError;
|
|
41
|
+
/**
|
|
42
|
+
* Error thrown when bargs config validation fails.
|
|
43
|
+
*
|
|
44
|
+
* @param message - Description of what's invalid
|
|
45
|
+
* @param path - Dot-notation path to the invalid property (e.g.,
|
|
46
|
+
* "options.verbose.aliases[0]")
|
|
47
|
+
*/
|
|
48
|
+
class ValidationError extends BargsError {
|
|
49
|
+
path;
|
|
50
|
+
constructor(path, message) {
|
|
51
|
+
super(`Invalid config at "${path}": ${message}`);
|
|
52
|
+
this.name = 'ValidationError';
|
|
53
|
+
this.path = path;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.ValidationError = ValidationError;
|
|
57
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAEH;;GAEG;AACH,MAAa,UAAW,SAAQ,KAAK;IACnC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF;AALD,gCAKC;AAED;;;;;;GAMG;AACH,MAAa,SAAU,SAAQ,UAAU;IAC9B,OAAO,CAAU;IAE1B,YAAY,OAAe,EAAE,OAAgB;QAC3C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AARD,8BAQC;AAED;;;;;;GAMG;AACH,MAAa,eAAgB,SAAQ,UAAU;IACpC,IAAI,CAAS;IAEtB,YAAY,IAAY,EAAE,OAAe;QACvC,KAAK,CAAC,sBAAsB,IAAI,MAAM,OAAO,EAAE,CAAC,CAAC;QACjD,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AARD,0CAQC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom error classes for bargs.
|
|
3
|
+
*
|
|
4
|
+
* Defines the error hierarchy used throughout bargs:
|
|
5
|
+
*
|
|
6
|
+
* - {@link BargsError} - Base class for all bargs errors
|
|
7
|
+
* - {@link HelpError} - Triggers help text display when user needs guidance
|
|
8
|
+
* - {@link ValidationError} - Thrown when configuration validation fails
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Custom error class for bargs errors.
|
|
14
|
+
*/
|
|
15
|
+
export declare class BargsError extends Error {
|
|
16
|
+
constructor(message: string);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Error that triggers help text display. Thrown when the user needs guidance.
|
|
20
|
+
*
|
|
21
|
+
* @param message - Error message to show before help text
|
|
22
|
+
* @param command - Command name for command-specific help, undefined for
|
|
23
|
+
* general help
|
|
24
|
+
*/
|
|
25
|
+
export declare class HelpError extends BargsError {
|
|
26
|
+
readonly command?: string;
|
|
27
|
+
constructor(message: string, command?: string);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Error thrown when bargs config validation fails.
|
|
31
|
+
*
|
|
32
|
+
* @param message - Description of what's invalid
|
|
33
|
+
* @param path - Dot-notation path to the invalid property (e.g.,
|
|
34
|
+
* "options.verbose.aliases[0]")
|
|
35
|
+
*/
|
|
36
|
+
export declare class ValidationError extends BargsError {
|
|
37
|
+
readonly path: string;
|
|
38
|
+
constructor(path: string, message: string);
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;GAEG;AACH,qBAAa,UAAW,SAAQ,KAAK;gBACvB,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;GAMG;AACH,qBAAa,SAAU,SAAQ,UAAU;IACvC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;gBAEd,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;CAK9C;AAED;;;;;;GAMG;AACH,qBAAa,eAAgB,SAAQ,UAAU;IAC7C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAK1C"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom error classes for bargs.
|
|
3
|
+
*
|
|
4
|
+
* Defines the error hierarchy used throughout bargs:
|
|
5
|
+
*
|
|
6
|
+
* - {@link BargsError} - Base class for all bargs errors
|
|
7
|
+
* - {@link HelpError} - Triggers help text display when user needs guidance
|
|
8
|
+
* - {@link ValidationError} - Thrown when configuration validation fails
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Custom error class for bargs errors.
|
|
14
|
+
*/
|
|
15
|
+
export declare class BargsError extends Error {
|
|
16
|
+
constructor(message: string);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Error that triggers help text display. Thrown when the user needs guidance.
|
|
20
|
+
*
|
|
21
|
+
* @param message - Error message to show before help text
|
|
22
|
+
* @param command - Command name for command-specific help, undefined for
|
|
23
|
+
* general help
|
|
24
|
+
*/
|
|
25
|
+
export declare class HelpError extends BargsError {
|
|
26
|
+
readonly command?: string;
|
|
27
|
+
constructor(message: string, command?: string);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Error thrown when bargs config validation fails.
|
|
31
|
+
*
|
|
32
|
+
* @param message - Description of what's invalid
|
|
33
|
+
* @param path - Dot-notation path to the invalid property (e.g.,
|
|
34
|
+
* "options.verbose.aliases[0]")
|
|
35
|
+
*/
|
|
36
|
+
export declare class ValidationError extends BargsError {
|
|
37
|
+
readonly path: string;
|
|
38
|
+
constructor(path: string, message: string);
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;GAEG;AACH,qBAAa,UAAW,SAAQ,KAAK;gBACvB,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;GAMG;AACH,qBAAa,SAAU,SAAQ,UAAU;IACvC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;gBAEd,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;CAK9C;AAED;;;;;;GAMG;AACH,qBAAa,eAAgB,SAAQ,UAAU;IAC7C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAK1C"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom error classes for bargs.
|
|
3
|
+
*
|
|
4
|
+
* Defines the error hierarchy used throughout bargs:
|
|
5
|
+
*
|
|
6
|
+
* - {@link BargsError} - Base class for all bargs errors
|
|
7
|
+
* - {@link HelpError} - Triggers help text display when user needs guidance
|
|
8
|
+
* - {@link ValidationError} - Thrown when configuration validation fails
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Custom error class for bargs errors.
|
|
14
|
+
*/
|
|
15
|
+
export class BargsError extends Error {
|
|
16
|
+
constructor(message) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.name = 'BargsError';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Error that triggers help text display. Thrown when the user needs guidance.
|
|
23
|
+
*
|
|
24
|
+
* @param message - Error message to show before help text
|
|
25
|
+
* @param command - Command name for command-specific help, undefined for
|
|
26
|
+
* general help
|
|
27
|
+
*/
|
|
28
|
+
export class HelpError extends BargsError {
|
|
29
|
+
command;
|
|
30
|
+
constructor(message, command) {
|
|
31
|
+
super(message);
|
|
32
|
+
this.name = 'HelpError';
|
|
33
|
+
this.command = command;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Error thrown when bargs config validation fails.
|
|
38
|
+
*
|
|
39
|
+
* @param message - Description of what's invalid
|
|
40
|
+
* @param path - Dot-notation path to the invalid property (e.g.,
|
|
41
|
+
* "options.verbose.aliases[0]")
|
|
42
|
+
*/
|
|
43
|
+
export class ValidationError extends BargsError {
|
|
44
|
+
path;
|
|
45
|
+
constructor(path, message) {
|
|
46
|
+
super(`Invalid config at "${path}": ${message}`);
|
|
47
|
+
this.name = 'ValidationError';
|
|
48
|
+
this.path = path;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,KAAK;IACnC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,OAAO,SAAU,SAAQ,UAAU;IAC9B,OAAO,CAAU;IAE1B,YAAY,OAAe,EAAE,OAAgB;QAC3C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,OAAO,eAAgB,SAAQ,UAAU;IACpC,IAAI,CAAS;IAEtB,YAAY,IAAY,EAAE,OAAe;QACvC,KAAK,CAAC,sBAAsB,IAAI,MAAM,OAAO,EAAE,CAAC,CAAC;QACjD,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF"}
|