@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
package/dist/parser.js
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Low-level argument parsing logic wrapping Node.js `util.parseArgs()`.
|
|
3
|
+
*
|
|
4
|
+
* Handles the transformation of CLI arguments into typed values by:
|
|
5
|
+
*
|
|
6
|
+
* - Building `parseArgs` configuration from bargs option schemas
|
|
7
|
+
* - Coercing parsed string values to their declared types (number, enum, etc.)
|
|
8
|
+
* - Processing positional arguments including variadic rest args
|
|
9
|
+
* - Running handler functions (sync or async) after successful parsing
|
|
10
|
+
* - Supporting both simple CLIs and command-based CLIs with subcommand dispatch
|
|
11
|
+
*
|
|
12
|
+
* @packageDocumentation
|
|
13
|
+
*/
|
|
14
|
+
import { parseArgs } from 'node:util';
|
|
15
|
+
import { BargsError, HelpError } from "./errors.js";
|
|
16
|
+
/**
|
|
17
|
+
* Check if a value is a thenable (Promise-like). Uses duck-typing for
|
|
18
|
+
* cross-realm compatibility.
|
|
19
|
+
*/
|
|
20
|
+
const isThenable = (value) => value !== null &&
|
|
21
|
+
typeof value === 'object' &&
|
|
22
|
+
typeof value.then === 'function';
|
|
23
|
+
/**
|
|
24
|
+
* Run a handler or array of handlers synchronously. Throws if any handler
|
|
25
|
+
* returns a thenable.
|
|
26
|
+
*/
|
|
27
|
+
export const runSyncHandlers = (handler, result) => {
|
|
28
|
+
const handlers = Array.isArray(handler) ? handler : [handler];
|
|
29
|
+
for (const h of handlers) {
|
|
30
|
+
const maybePromise = h(result);
|
|
31
|
+
if (isThenable(maybePromise)) {
|
|
32
|
+
throw new BargsError('Handler returned a thenable. Use bargsAsync() for async handlers.');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Run a handler or array of handlers sequentially (async).
|
|
38
|
+
*/
|
|
39
|
+
export const runHandlers = async (handler, result) => {
|
|
40
|
+
const handlers = Array.isArray(handler) ? handler : [handler];
|
|
41
|
+
for (const h of handlers) {
|
|
42
|
+
await h(result);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Build parseArgs options config from our options schema.
|
|
47
|
+
*/
|
|
48
|
+
const buildParseArgsConfig = (schema) => {
|
|
49
|
+
const config = {};
|
|
50
|
+
for (const [name, def] of Object.entries(schema)) {
|
|
51
|
+
const opt = {
|
|
52
|
+
type: def.type === 'boolean' ? 'boolean' : 'string',
|
|
53
|
+
};
|
|
54
|
+
// First single-char alias becomes short option
|
|
55
|
+
const shortAlias = def.aliases?.find((a) => a.length === 1);
|
|
56
|
+
if (shortAlias) {
|
|
57
|
+
opt.short = shortAlias;
|
|
58
|
+
}
|
|
59
|
+
// Arrays need multiple: true
|
|
60
|
+
if (def.type === 'array') {
|
|
61
|
+
opt.multiple = true;
|
|
62
|
+
}
|
|
63
|
+
config[name] = opt;
|
|
64
|
+
}
|
|
65
|
+
return config;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Coerce parsed values to their expected types.
|
|
69
|
+
*/
|
|
70
|
+
const coerceValues = (values, schema) => {
|
|
71
|
+
const result = {};
|
|
72
|
+
for (const [name, def] of Object.entries(schema)) {
|
|
73
|
+
let value = values[name];
|
|
74
|
+
// Apply default if undefined
|
|
75
|
+
if (value === undefined && 'default' in def) {
|
|
76
|
+
value = def.default;
|
|
77
|
+
}
|
|
78
|
+
// Type coercion
|
|
79
|
+
if (value !== undefined) {
|
|
80
|
+
switch (def.type) {
|
|
81
|
+
case 'array':
|
|
82
|
+
if (def.items === 'number' && Array.isArray(value)) {
|
|
83
|
+
result[name] = value.map((v) => (typeof v === 'string' ? Number(v) : v));
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
result[name] = value;
|
|
87
|
+
}
|
|
88
|
+
break;
|
|
89
|
+
case 'count':
|
|
90
|
+
// Count options count occurrences
|
|
91
|
+
result[name] = typeof value === 'number' ? value : value ? 1 : 0;
|
|
92
|
+
break;
|
|
93
|
+
case 'enum': {
|
|
94
|
+
const enumValue = value;
|
|
95
|
+
if (value !== undefined && !def.choices.includes(enumValue)) {
|
|
96
|
+
throw new Error(`Invalid value for --${name}: "${enumValue}". Must be one of: ${def.choices.join(', ')}`);
|
|
97
|
+
}
|
|
98
|
+
result[name] = value;
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
case 'number':
|
|
102
|
+
result[name] = typeof value === 'string' ? Number(value) : value;
|
|
103
|
+
break;
|
|
104
|
+
default:
|
|
105
|
+
result[name] = value;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
result[name] = value;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return result;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Coerce positional values.
|
|
116
|
+
*
|
|
117
|
+
* Note: Schema validation (variadic last, required order) is done upfront by
|
|
118
|
+
* validateConfig in bargs.ts.
|
|
119
|
+
*/
|
|
120
|
+
const coercePositionals = (positionals, schema) => {
|
|
121
|
+
const result = [];
|
|
122
|
+
for (let i = 0; i < schema.length; i++) {
|
|
123
|
+
const def = schema[i];
|
|
124
|
+
const value = positionals[i];
|
|
125
|
+
if (def.type === 'variadic') {
|
|
126
|
+
// Rest of positionals - def is narrowed to VariadicPositional here
|
|
127
|
+
const variadicDef = def;
|
|
128
|
+
const rest = positionals.slice(i);
|
|
129
|
+
if (variadicDef.items === 'number') {
|
|
130
|
+
result.push(rest.map(Number));
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
result.push(rest);
|
|
134
|
+
}
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
if (value !== undefined) {
|
|
138
|
+
if (def.type === 'number') {
|
|
139
|
+
result.push(Number(value));
|
|
140
|
+
}
|
|
141
|
+
else if (def.type === 'enum') {
|
|
142
|
+
// Validate enum choice
|
|
143
|
+
if (!def.choices.includes(value)) {
|
|
144
|
+
throw new Error(`Invalid value for positional ${i}: "${value}". Must be one of: ${def.choices.join(', ')}`);
|
|
145
|
+
}
|
|
146
|
+
result.push(value);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
result.push(value);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
else if ('default' in def && def.default !== undefined) {
|
|
153
|
+
result.push(def.default);
|
|
154
|
+
}
|
|
155
|
+
else if (def.required) {
|
|
156
|
+
throw new Error(`Missing required positional argument at position ${i}`);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
result.push(undefined);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return result;
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* Parse arguments for a simple CLI (no commands). This is synchronous - it only
|
|
166
|
+
* parses, does not run handlers.
|
|
167
|
+
*/
|
|
168
|
+
export const parseSimple = (config) => {
|
|
169
|
+
const { args = process.argv.slice(2), options: optionsSchema = {}, positionals: positionalsSchema = [], } = config;
|
|
170
|
+
// Build parseArgs config
|
|
171
|
+
const parseArgsOptions = buildParseArgsConfig(optionsSchema);
|
|
172
|
+
// Parse with Node.js util.parseArgs
|
|
173
|
+
const { positionals, values } = parseArgs({
|
|
174
|
+
allowPositionals: positionalsSchema.length > 0,
|
|
175
|
+
args,
|
|
176
|
+
options: parseArgsOptions,
|
|
177
|
+
strict: true,
|
|
178
|
+
});
|
|
179
|
+
// Coerce and apply defaults
|
|
180
|
+
const coercedValues = coerceValues(values, optionsSchema);
|
|
181
|
+
const coercedPositionals = coercePositionals(positionals, positionalsSchema);
|
|
182
|
+
return {
|
|
183
|
+
command: undefined,
|
|
184
|
+
positionals: coercedPositionals,
|
|
185
|
+
values: coercedValues,
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* Core command parsing logic (sync, no handler execution). Returns the parsed
|
|
190
|
+
* result and the handler to run.
|
|
191
|
+
*/
|
|
192
|
+
const parseCommandsCore = (config) => {
|
|
193
|
+
const { args = process.argv.slice(2), commands, defaultHandler, options: globalOptions = {}, } = config;
|
|
194
|
+
const commandsRecord = commands;
|
|
195
|
+
// Find command name (first non-flag argument)
|
|
196
|
+
const commandIndex = args.findIndex((arg) => !arg.startsWith('-'));
|
|
197
|
+
const commandName = commandIndex >= 0 ? args[commandIndex] : undefined;
|
|
198
|
+
const remainingArgs = commandName
|
|
199
|
+
? [...args.slice(0, commandIndex), ...args.slice(commandIndex + 1)]
|
|
200
|
+
: args;
|
|
201
|
+
// No command specified
|
|
202
|
+
if (!commandName) {
|
|
203
|
+
if (typeof defaultHandler === 'string') {
|
|
204
|
+
// Use named default command (recursive)
|
|
205
|
+
return parseCommandsCore({
|
|
206
|
+
...config,
|
|
207
|
+
args: [defaultHandler, ...args],
|
|
208
|
+
defaultHandler: undefined,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
else if (typeof defaultHandler === 'function' ||
|
|
212
|
+
Array.isArray(defaultHandler)) {
|
|
213
|
+
// Parse global options only
|
|
214
|
+
const parseArgsOptions = buildParseArgsConfig(globalOptions);
|
|
215
|
+
const { values } = parseArgs({
|
|
216
|
+
allowPositionals: false,
|
|
217
|
+
args: remainingArgs,
|
|
218
|
+
options: parseArgsOptions,
|
|
219
|
+
strict: true,
|
|
220
|
+
});
|
|
221
|
+
const coercedValues = coerceValues(values, globalOptions);
|
|
222
|
+
const result = {
|
|
223
|
+
command: undefined,
|
|
224
|
+
positionals: [],
|
|
225
|
+
values: coercedValues,
|
|
226
|
+
};
|
|
227
|
+
return {
|
|
228
|
+
handler: defaultHandler,
|
|
229
|
+
result,
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
throw new HelpError('No command specified.');
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
// Find command config
|
|
237
|
+
const command = commandsRecord[commandName];
|
|
238
|
+
if (!command) {
|
|
239
|
+
throw new HelpError(`Unknown command: ${commandName}`);
|
|
240
|
+
}
|
|
241
|
+
// Merge global and command options
|
|
242
|
+
const commandOptions = command.options ?? {};
|
|
243
|
+
const mergedOptionsSchema = { ...globalOptions, ...commandOptions };
|
|
244
|
+
const commandPositionals = command.positionals ?? [];
|
|
245
|
+
// Build parseArgs config
|
|
246
|
+
const parseArgsOptions = buildParseArgsConfig(mergedOptionsSchema);
|
|
247
|
+
// Parse
|
|
248
|
+
const { positionals, values } = parseArgs({
|
|
249
|
+
allowPositionals: commandPositionals.length > 0,
|
|
250
|
+
args: remainingArgs,
|
|
251
|
+
options: parseArgsOptions,
|
|
252
|
+
strict: true,
|
|
253
|
+
});
|
|
254
|
+
// Coerce
|
|
255
|
+
const coercedValues = coerceValues(values, mergedOptionsSchema);
|
|
256
|
+
const coercedPositionals = coercePositionals(positionals, commandPositionals);
|
|
257
|
+
const result = {
|
|
258
|
+
command: commandName,
|
|
259
|
+
positionals: coercedPositionals,
|
|
260
|
+
values: coercedValues,
|
|
261
|
+
};
|
|
262
|
+
return { handler: command.handler, result };
|
|
263
|
+
};
|
|
264
|
+
/**
|
|
265
|
+
* Parse arguments for a command-based CLI (sync). Throws if any handler returns
|
|
266
|
+
* a thenable.
|
|
267
|
+
*/
|
|
268
|
+
export const parseCommandsSync = (config) => {
|
|
269
|
+
const { handler, result } = parseCommandsCore(config);
|
|
270
|
+
if (handler) {
|
|
271
|
+
runSyncHandlers(handler, result);
|
|
272
|
+
}
|
|
273
|
+
return result;
|
|
274
|
+
};
|
|
275
|
+
/**
|
|
276
|
+
* Parse arguments for a command-based CLI (async).
|
|
277
|
+
*/
|
|
278
|
+
export const parseCommandsAsync = async (config) => {
|
|
279
|
+
const { handler, result } = parseCommandsCore(config);
|
|
280
|
+
if (handler) {
|
|
281
|
+
await runHandlers(handler, result);
|
|
282
|
+
}
|
|
283
|
+
return result;
|
|
284
|
+
};
|
|
285
|
+
//# sourceMappingURL=parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAatC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,oBAAoB;AAEpD;;;GAGG;AACH,MAAM,UAAU,GAAG,CAAC,KAAc,EAAiC,EAAE,CACnE,KAAK,KAAK,IAAI;IACd,OAAO,KAAK,KAAK,QAAQ;IACzB,OAAQ,KAA4B,CAAC,IAAI,KAAK,UAAU,CAAC;AAE3D;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,OAAsC,EACtC,MAAS,EACH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D,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;AAC9C,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAO/B,MAAoD,EACgB,EAAE;IACtE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAEtD,IAAI,OAAO,EAAE,CAAC;QACZ,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EAOrC,MAAoD,EAGpD,EAAE;IACF,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAEtD,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACrC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
package/dist/theme.cjs
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Theming system for colorized help output.
|
|
4
|
+
*
|
|
5
|
+
* Provides ANSI color codes, built-in themes (default, mono, ocean, warm), and
|
|
6
|
+
* utilities for creating custom themes. Each theme defines colors for semantic
|
|
7
|
+
* elements like flags, commands, descriptions, and section headers. Themes can
|
|
8
|
+
* be customized by overriding individual color properties.
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.createStyler = exports.getTheme = exports.defaultTheme = exports.themes = exports.ansi = exports.stripAnsi = void 0;
|
|
14
|
+
const node_util_1 = require("node:util");
|
|
15
|
+
/**
|
|
16
|
+
* Strip all ANSI escape codes from a string.
|
|
17
|
+
*/
|
|
18
|
+
exports.stripAnsi = node_util_1.stripVTControlCharacters;
|
|
19
|
+
/**
|
|
20
|
+
* ANSI escape codes for building custom themes.
|
|
21
|
+
*
|
|
22
|
+
* Includes text styles (bold, italic, underline, etc.), foreground colors,
|
|
23
|
+
* bright foreground colors, background colors, and bright background colors.
|
|
24
|
+
*/
|
|
25
|
+
exports.ansi = {
|
|
26
|
+
bgBlack: '\x1b[40m',
|
|
27
|
+
bgBlue: '\x1b[44m',
|
|
28
|
+
bgBrightBlack: '\x1b[100m',
|
|
29
|
+
bgBrightBlue: '\x1b[104m',
|
|
30
|
+
bgBrightCyan: '\x1b[106m',
|
|
31
|
+
bgBrightGreen: '\x1b[102m',
|
|
32
|
+
bgBrightMagenta: '\x1b[105m',
|
|
33
|
+
bgBrightRed: '\x1b[101m',
|
|
34
|
+
bgBrightWhite: '\x1b[107m',
|
|
35
|
+
bgBrightYellow: '\x1b[103m',
|
|
36
|
+
bgCyan: '\x1b[46m',
|
|
37
|
+
bgGreen: '\x1b[42m',
|
|
38
|
+
bgMagenta: '\x1b[45m',
|
|
39
|
+
bgRed: '\x1b[41m',
|
|
40
|
+
bgWhite: '\x1b[47m',
|
|
41
|
+
bgYellow: '\x1b[43m',
|
|
42
|
+
black: '\x1b[30m',
|
|
43
|
+
blue: '\x1b[34m',
|
|
44
|
+
bold: '\x1b[1m',
|
|
45
|
+
brightBlack: '\x1b[90m',
|
|
46
|
+
brightBlue: '\x1b[94m',
|
|
47
|
+
brightCyan: '\x1b[96m',
|
|
48
|
+
brightGreen: '\x1b[92m',
|
|
49
|
+
brightMagenta: '\x1b[95m',
|
|
50
|
+
brightRed: '\x1b[91m',
|
|
51
|
+
brightWhite: '\x1b[97m',
|
|
52
|
+
brightYellow: '\x1b[93m',
|
|
53
|
+
cyan: '\x1b[36m',
|
|
54
|
+
dim: '\x1b[2m',
|
|
55
|
+
green: '\x1b[32m',
|
|
56
|
+
hidden: '\x1b[8m',
|
|
57
|
+
inverse: '\x1b[7m',
|
|
58
|
+
italic: '\x1b[3m',
|
|
59
|
+
magenta: '\x1b[35m',
|
|
60
|
+
red: '\x1b[31m',
|
|
61
|
+
reset: '\x1b[0m',
|
|
62
|
+
strikethrough: '\x1b[9m',
|
|
63
|
+
underline: '\x1b[4m',
|
|
64
|
+
white: '\x1b[37m',
|
|
65
|
+
yellow: '\x1b[33m',
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Default color values used when theme colors are not specified.
|
|
69
|
+
*/
|
|
70
|
+
const defaultColors = {
|
|
71
|
+
command: exports.ansi.bold,
|
|
72
|
+
defaultText: exports.ansi.dim,
|
|
73
|
+
defaultValue: exports.ansi.white,
|
|
74
|
+
description: exports.ansi.white,
|
|
75
|
+
epilog: exports.ansi.dim,
|
|
76
|
+
example: exports.ansi.white + exports.ansi.dim,
|
|
77
|
+
flag: exports.ansi.brightCyan,
|
|
78
|
+
positional: exports.ansi.magenta,
|
|
79
|
+
scriptName: exports.ansi.bold,
|
|
80
|
+
sectionHeader: exports.ansi.brightMagenta,
|
|
81
|
+
type: exports.ansi.magenta,
|
|
82
|
+
url: exports.ansi.cyan,
|
|
83
|
+
usage: exports.ansi.cyan,
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Built-in themes.
|
|
87
|
+
*/
|
|
88
|
+
exports.themes = {
|
|
89
|
+
/** Default colorful theme */
|
|
90
|
+
default: {
|
|
91
|
+
colors: { ...defaultColors },
|
|
92
|
+
},
|
|
93
|
+
/** No colors (monochrome) */
|
|
94
|
+
mono: {
|
|
95
|
+
colors: {
|
|
96
|
+
command: '',
|
|
97
|
+
defaultText: '',
|
|
98
|
+
defaultValue: '',
|
|
99
|
+
description: '',
|
|
100
|
+
epilog: '',
|
|
101
|
+
example: '',
|
|
102
|
+
flag: '',
|
|
103
|
+
positional: '',
|
|
104
|
+
scriptName: '',
|
|
105
|
+
sectionHeader: '',
|
|
106
|
+
type: '',
|
|
107
|
+
url: '',
|
|
108
|
+
usage: '',
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
/** Ocean theme - blues and greens (bright) */
|
|
112
|
+
ocean: {
|
|
113
|
+
colors: {
|
|
114
|
+
command: exports.ansi.bold + exports.ansi.brightCyan,
|
|
115
|
+
defaultText: exports.ansi.blue,
|
|
116
|
+
defaultValue: exports.ansi.green,
|
|
117
|
+
description: exports.ansi.white,
|
|
118
|
+
epilog: exports.ansi.blue,
|
|
119
|
+
example: exports.ansi.dim + exports.ansi.white,
|
|
120
|
+
flag: exports.ansi.brightCyan,
|
|
121
|
+
positional: exports.ansi.brightGreen,
|
|
122
|
+
scriptName: exports.ansi.bold + exports.ansi.brightBlue,
|
|
123
|
+
sectionHeader: exports.ansi.brightBlue,
|
|
124
|
+
type: exports.ansi.cyan,
|
|
125
|
+
url: exports.ansi.brightCyan,
|
|
126
|
+
usage: exports.ansi.white,
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
/** Warm theme - reds and yellows */
|
|
130
|
+
warm: {
|
|
131
|
+
colors: {
|
|
132
|
+
command: exports.ansi.bold + exports.ansi.yellow,
|
|
133
|
+
defaultText: exports.ansi.dim + exports.ansi.yellow,
|
|
134
|
+
defaultValue: exports.ansi.brightYellow,
|
|
135
|
+
description: exports.ansi.white,
|
|
136
|
+
epilog: exports.ansi.dim + exports.ansi.yellow,
|
|
137
|
+
example: exports.ansi.white + exports.ansi.dim,
|
|
138
|
+
flag: exports.ansi.brightYellow,
|
|
139
|
+
positional: exports.ansi.brightRed,
|
|
140
|
+
scriptName: exports.ansi.bold + exports.ansi.red,
|
|
141
|
+
sectionHeader: exports.ansi.red,
|
|
142
|
+
type: exports.ansi.yellow,
|
|
143
|
+
url: exports.ansi.brightYellow,
|
|
144
|
+
usage: exports.ansi.white,
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Default theme export for convenience.
|
|
150
|
+
*/
|
|
151
|
+
exports.defaultTheme = exports.themes.default;
|
|
152
|
+
/**
|
|
153
|
+
* Resolve a theme input to a fully resolved Theme with all colors defined.
|
|
154
|
+
* Missing colors fall back to the default theme.
|
|
155
|
+
*/
|
|
156
|
+
const getTheme = (input) => {
|
|
157
|
+
if (typeof input === 'string') {
|
|
158
|
+
return exports.themes[input];
|
|
159
|
+
}
|
|
160
|
+
// Merge with defaults for partial themes
|
|
161
|
+
return {
|
|
162
|
+
colors: { ...defaultColors, ...input.colors },
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
exports.getTheme = getTheme;
|
|
166
|
+
/**
|
|
167
|
+
* ANSI reset code.
|
|
168
|
+
*/
|
|
169
|
+
const RESET = '\x1b[0m';
|
|
170
|
+
/**
|
|
171
|
+
* Create a style function from a color code. Returns passthrough if color is
|
|
172
|
+
* empty.
|
|
173
|
+
*/
|
|
174
|
+
const makeStyleFn = (color) => {
|
|
175
|
+
if (!color) {
|
|
176
|
+
return (text) => text;
|
|
177
|
+
}
|
|
178
|
+
return (text) => `${color}${text}${RESET}`;
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Create a Styler from a Theme. If the theme has missing colors, they fall back
|
|
182
|
+
* to the default theme.
|
|
183
|
+
*/
|
|
184
|
+
const createStyler = (theme) => {
|
|
185
|
+
const resolved = (0, exports.getTheme)(theme);
|
|
186
|
+
return {
|
|
187
|
+
command: makeStyleFn(resolved.colors.command),
|
|
188
|
+
defaultText: makeStyleFn(resolved.colors.defaultText),
|
|
189
|
+
defaultValue: makeStyleFn(resolved.colors.defaultValue),
|
|
190
|
+
description: makeStyleFn(resolved.colors.description),
|
|
191
|
+
epilog: makeStyleFn(resolved.colors.epilog),
|
|
192
|
+
example: makeStyleFn(resolved.colors.example),
|
|
193
|
+
flag: makeStyleFn(resolved.colors.flag),
|
|
194
|
+
positional: makeStyleFn(resolved.colors.positional),
|
|
195
|
+
scriptName: makeStyleFn(resolved.colors.scriptName),
|
|
196
|
+
sectionHeader: makeStyleFn(resolved.colors.sectionHeader),
|
|
197
|
+
type: makeStyleFn(resolved.colors.type),
|
|
198
|
+
url: makeStyleFn(resolved.colors.url),
|
|
199
|
+
usage: makeStyleFn(resolved.colors.usage),
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
exports.createStyler = createStyler;
|
|
203
|
+
//# sourceMappingURL=theme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAEH,yCAAqD;AAErD;;GAEG;AACU,QAAA,SAAS,GAAG,oCAAwB,CAAC;AAuDlD;;;;;GAKG;AACU,QAAA,IAAI,GAAG;IAClB,OAAO,EAAE,UAAU;IACnB,MAAM,EAAE,UAAU;IAClB,aAAa,EAAE,WAAW;IAC1B,YAAY,EAAE,WAAW;IACzB,YAAY,EAAE,WAAW;IACzB,aAAa,EAAE,WAAW;IAC1B,eAAe,EAAE,WAAW;IAC5B,WAAW,EAAE,WAAW;IACxB,aAAa,EAAE,WAAW;IAC1B,cAAc,EAAE,WAAW;IAC3B,MAAM,EAAE,UAAU;IAClB,OAAO,EAAE,UAAU;IACnB,SAAS,EAAE,UAAU;IACrB,KAAK,EAAE,UAAU;IACjB,OAAO,EAAE,UAAU;IACnB,QAAQ,EAAE,UAAU;IACpB,KAAK,EAAE,UAAU;IACjB,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,SAAS;IACf,WAAW,EAAE,UAAU;IACvB,UAAU,EAAE,UAAU;IACtB,UAAU,EAAE,UAAU;IACtB,WAAW,EAAE,UAAU;IACvB,aAAa,EAAE,UAAU;IACzB,SAAS,EAAE,UAAU;IACrB,WAAW,EAAE,UAAU;IACvB,YAAY,EAAE,UAAU;IACxB,IAAI,EAAE,UAAU;IAChB,GAAG,EAAE,SAAS;IACd,KAAK,EAAE,UAAU;IACjB,MAAM,EAAE,SAAS;IACjB,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,SAAS;IACj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