politty 0.2.0 → 0.2.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/dist/docs/index.cjs +31 -20
- package/dist/docs/index.cjs.map +1 -1
- package/dist/docs/index.d.cts +6 -6
- package/dist/docs/index.d.cts.map +1 -1
- package/dist/docs/index.d.ts +6 -6
- package/dist/docs/index.d.ts.map +1 -1
- package/dist/docs/index.js +31 -20
- package/dist/docs/index.js.map +1 -1
- package/dist/index.cjs +3 -1
- package/dist/index.d.cts +30 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +30 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/{runner-CyxuNkT1.js → runner-B_D1BQNi.js} +247 -9
- package/dist/runner-B_D1BQNi.js.map +1 -0
- package/dist/runner-C2j9KgSI.js +4 -0
- package/dist/runner-DdljTA5L.cjs +4 -0
- package/dist/{runner-ttyvfYGi.cjs → runner-sZdqdKBN.cjs} +258 -8
- package/dist/runner-sZdqdKBN.cjs.map +1 -0
- package/package.json +21 -24
- package/dist/runner-BkhekqT9.cjs +0 -4
- package/dist/runner-CyxuNkT1.js.map +0 -1
- package/dist/runner-DzzbIwEy.js +0 -4
- package/dist/runner-ttyvfYGi.cjs.map +0 -1
package/dist/docs/index.cjs
CHANGED
|
@@ -113,32 +113,33 @@ function formatOptionFlags(opt) {
|
|
|
113
113
|
* - Displays multiple env vars as comma-separated list
|
|
114
114
|
*
|
|
115
115
|
* @example
|
|
116
|
-
* | Option | Alias | Description | Default | Env |
|
|
117
|
-
*
|
|
118
|
-
* | `--dry-run` | `-d` | Dry run mode | `false` | - |
|
|
119
|
-
* | `--port <PORT>` | - | Server port | - | `PORT`, `SERVER_PORT` |
|
|
116
|
+
* | Option | Alias | Description | Required | Default | Env |
|
|
117
|
+
* |--------|-------|-------------|----------|---------|-----|
|
|
118
|
+
* | `--dry-run` | `-d` | Dry run mode | No | `false` | - |
|
|
119
|
+
* | `--port <PORT>` | - | Server port | Yes | - | `PORT`, `SERVER_PORT` |
|
|
120
120
|
*/
|
|
121
121
|
function renderOptionsTable(info) {
|
|
122
122
|
if (info.options.length === 0) return "";
|
|
123
123
|
const hasEnv = info.options.some((opt) => opt.env);
|
|
124
124
|
const lines = [];
|
|
125
125
|
if (hasEnv) {
|
|
126
|
-
lines.push("| Option | Alias | Description | Default | Env |");
|
|
127
|
-
lines.push("
|
|
126
|
+
lines.push("| Option | Alias | Description | Required | Default | Env |");
|
|
127
|
+
lines.push("|--------|-------|-------------|----------|---------|-----|");
|
|
128
128
|
} else {
|
|
129
|
-
lines.push("| Option | Alias | Description | Default |");
|
|
130
|
-
lines.push("
|
|
129
|
+
lines.push("| Option | Alias | Description | Required | Default |");
|
|
130
|
+
lines.push("|--------|-------|-------------|----------|---------|");
|
|
131
131
|
}
|
|
132
132
|
for (const opt of info.options) {
|
|
133
133
|
const placeholder = opt.placeholder ?? opt.cliName.toUpperCase().replace(/-/g, "_");
|
|
134
134
|
const optionName = opt.type === "boolean" ? `\`--${opt.cliName}\`` : `\`--${opt.cliName} <${placeholder}>\``;
|
|
135
135
|
const alias = opt.alias ? `\`-${opt.alias}\`` : "-";
|
|
136
136
|
const desc = escapeTableCell$2(opt.description ?? "");
|
|
137
|
+
const required = opt.required ? "Yes" : "No";
|
|
137
138
|
const defaultVal = formatDefaultValue$1(opt.defaultValue);
|
|
138
139
|
if (hasEnv) {
|
|
139
140
|
const envNames = opt.env ? Array.isArray(opt.env) ? opt.env.map((e) => `\`${e}\``).join(", ") : `\`${opt.env}\`` : "-";
|
|
140
|
-
lines.push(`| ${optionName} | ${alias} | ${desc} | ${defaultVal} | ${envNames} |`);
|
|
141
|
-
} else lines.push(`| ${optionName} | ${alias} | ${desc} | ${defaultVal} |`);
|
|
141
|
+
lines.push(`| ${optionName} | ${alias} | ${desc} | ${required} | ${defaultVal} | ${envNames} |`);
|
|
142
|
+
} else lines.push(`| ${optionName} | ${alias} | ${desc} | ${required} | ${defaultVal} |`);
|
|
142
143
|
}
|
|
143
144
|
return lines.join("\n");
|
|
144
145
|
}
|
|
@@ -151,7 +152,7 @@ function renderOptionsTable(info) {
|
|
|
151
152
|
*
|
|
152
153
|
* @example
|
|
153
154
|
* - `-d`, `--dry-run` - Dry run mode (default: false)
|
|
154
|
-
* - `--port <PORT>` - Server port [env: PORT, SERVER_PORT]
|
|
155
|
+
* - `--port <PORT>` - Server port (required) [env: PORT, SERVER_PORT]
|
|
155
156
|
*/
|
|
156
157
|
function renderOptionsList(info) {
|
|
157
158
|
if (info.options.length === 0) return "";
|
|
@@ -159,9 +160,10 @@ function renderOptionsList(info) {
|
|
|
159
160
|
for (const opt of info.options) {
|
|
160
161
|
const flags = formatOptionFlags(opt);
|
|
161
162
|
const desc = opt.description ? ` - ${opt.description}` : "";
|
|
163
|
+
const required = opt.required ? " (required)" : "";
|
|
162
164
|
const defaultVal = opt.defaultValue !== void 0 ? ` (default: ${JSON.stringify(opt.defaultValue)})` : "";
|
|
163
165
|
const envInfo = formatEnvInfo(opt.env);
|
|
164
|
-
lines.push(`- ${flags}${desc}${defaultVal}${envInfo}`);
|
|
166
|
+
lines.push(`- ${flags}${desc}${required}${defaultVal}${envInfo}`);
|
|
165
167
|
}
|
|
166
168
|
return lines.join("\n");
|
|
167
169
|
}
|
|
@@ -215,22 +217,23 @@ function renderOptionsTableFromArray(options) {
|
|
|
215
217
|
const hasEnv = options.some((opt) => opt.env);
|
|
216
218
|
const lines = [];
|
|
217
219
|
if (hasEnv) {
|
|
218
|
-
lines.push("| Option | Alias | Description | Default | Env |");
|
|
219
|
-
lines.push("
|
|
220
|
+
lines.push("| Option | Alias | Description | Required | Default | Env |");
|
|
221
|
+
lines.push("|--------|-------|-------------|----------|---------|-----|");
|
|
220
222
|
} else {
|
|
221
|
-
lines.push("| Option | Alias | Description | Default |");
|
|
222
|
-
lines.push("
|
|
223
|
+
lines.push("| Option | Alias | Description | Required | Default |");
|
|
224
|
+
lines.push("|--------|-------|-------------|----------|---------|");
|
|
223
225
|
}
|
|
224
226
|
for (const opt of options) {
|
|
225
227
|
const placeholder = opt.placeholder ?? opt.cliName.toUpperCase().replace(/-/g, "_");
|
|
226
228
|
const optionName = opt.type === "boolean" ? `\`--${opt.cliName}\`` : `\`--${opt.cliName} <${placeholder}>\``;
|
|
227
229
|
const alias = opt.alias ? `\`-${opt.alias}\`` : "-";
|
|
228
230
|
const desc = escapeTableCell$2(opt.description ?? "");
|
|
231
|
+
const required = opt.required ? "Yes" : "No";
|
|
229
232
|
const defaultVal = formatDefaultValue$1(opt.defaultValue);
|
|
230
233
|
if (hasEnv) {
|
|
231
234
|
const envNames = opt.env ? Array.isArray(opt.env) ? opt.env.map((e) => `\`${e}\``).join(", ") : `\`${opt.env}\`` : "-";
|
|
232
|
-
lines.push(`| ${optionName} | ${alias} | ${desc} | ${defaultVal} | ${envNames} |`);
|
|
233
|
-
} else lines.push(`| ${optionName} | ${alias} | ${desc} | ${defaultVal} |`);
|
|
235
|
+
lines.push(`| ${optionName} | ${alias} | ${desc} | ${required} | ${defaultVal} | ${envNames} |`);
|
|
236
|
+
} else lines.push(`| ${optionName} | ${alias} | ${desc} | ${required} | ${defaultVal} |`);
|
|
234
237
|
}
|
|
235
238
|
return lines.join("\n");
|
|
236
239
|
}
|
|
@@ -243,9 +246,10 @@ function renderOptionsListFromArray(options) {
|
|
|
243
246
|
for (const opt of options) {
|
|
244
247
|
const flags = formatOptionFlags(opt);
|
|
245
248
|
const desc = opt.description ? ` - ${opt.description}` : "";
|
|
249
|
+
const required = opt.required ? " (required)" : "";
|
|
246
250
|
const defaultVal = opt.defaultValue !== void 0 ? ` (default: ${JSON.stringify(opt.defaultValue)})` : "";
|
|
247
251
|
const envInfo = formatEnvInfo(opt.env);
|
|
248
|
-
lines.push(`- ${flags}${desc}${defaultVal}${envInfo}`);
|
|
252
|
+
lines.push(`- ${flags}${desc}${required}${defaultVal}${envInfo}`);
|
|
249
253
|
}
|
|
250
254
|
return lines.join("\n");
|
|
251
255
|
}
|
|
@@ -676,7 +680,7 @@ async function executeSingleExample(example, rootCommand, commandPath) {
|
|
|
676
680
|
collector.start();
|
|
677
681
|
let success = true;
|
|
678
682
|
try {
|
|
679
|
-
const { runCommand } = await Promise.resolve().then(() => require("../runner-
|
|
683
|
+
const { runCommand } = await Promise.resolve().then(() => require("../runner-DdljTA5L.cjs"));
|
|
680
684
|
const result = await runCommand(rootCommand, argv);
|
|
681
685
|
success = result.success;
|
|
682
686
|
if (!result.success && result.error) console.error(result.error.message);
|
|
@@ -1284,6 +1288,10 @@ function renderFilteredTable(options, columns) {
|
|
|
1284
1288
|
headerCells.push("Description");
|
|
1285
1289
|
separatorCells.push("-----------");
|
|
1286
1290
|
break;
|
|
1291
|
+
case "required":
|
|
1292
|
+
headerCells.push("Required");
|
|
1293
|
+
separatorCells.push("--------");
|
|
1294
|
+
break;
|
|
1287
1295
|
case "default":
|
|
1288
1296
|
headerCells.push("Default");
|
|
1289
1297
|
separatorCells.push("-------");
|
|
@@ -1310,6 +1318,9 @@ function renderFilteredTable(options, columns) {
|
|
|
1310
1318
|
case "description":
|
|
1311
1319
|
cells.push(escapeTableCell$1(opt.description ?? ""));
|
|
1312
1320
|
break;
|
|
1321
|
+
case "required":
|
|
1322
|
+
cells.push(opt.required ? "Yes" : "No");
|
|
1323
|
+
break;
|
|
1313
1324
|
case "default":
|
|
1314
1325
|
cells.push(formatDefaultValue(opt.defaultValue));
|
|
1315
1326
|
break;
|