@kaynooo/cli-pick 0.11.5 → 0.11.6
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/pick.js +12 -6
- package/package.json +2 -2
package/dist/pick.js
CHANGED
|
@@ -386,7 +386,7 @@ var init_format = __esm(() => {
|
|
|
386
386
|
|
|
387
387
|
// ../kit/src/help.ts
|
|
388
388
|
import process8 from "process";
|
|
389
|
-
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
389
|
+
function usageLine(usage, colors = paint(process8.stdout), { summary: withSummary = true } = {}) {
|
|
390
390
|
const lines = usage.replace(USAGE_PREFIX, "").split(`
|
|
391
391
|
`);
|
|
392
392
|
const blank = lines.indexOf("");
|
|
@@ -399,7 +399,7 @@ function usageLine(usage, colors = paint(process8.stdout)) {
|
|
|
399
399
|
synopses[0] = synopses[0].slice(0, colon);
|
|
400
400
|
const head = `${colors.bold("Usage:")} ${synopses.map((line) => line.replaceAll(OPTIONAL, (part) => colors.dim(part))).join(`
|
|
401
401
|
`)}`;
|
|
402
|
-
const lead = summary === undefined ? [] : ["", colors.bold(prose(summary, colors))];
|
|
402
|
+
const lead = summary === undefined || !withSummary ? [] : ["", colors.bold(prose(summary, colors))];
|
|
403
403
|
const rest = details.length === 0 ? [] : ["", ...details.map((line) => prose(line, colors))];
|
|
404
404
|
return [head, ...lead, ...rest].join(`
|
|
405
405
|
`);
|
|
@@ -409,8 +409,10 @@ function prose(line, colors) {
|
|
|
409
409
|
return line;
|
|
410
410
|
return line.replaceAll(PROSE_MARKS, (match, code, flag) => code === undefined ? colors.cyan(flag ?? match) : colors.bold(code));
|
|
411
411
|
}
|
|
412
|
-
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
|
|
413
|
-
|
|
412
|
+
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [], bin } = {}) {
|
|
413
|
+
const { summary } = description(usage);
|
|
414
|
+
const head = bin === undefined ? [usageLine(usage, colors)] : [`${colors.bold(bin.name)} ${colors.dim(bin.version())}${summary === "" ? "" : ` ${summary}`}`, "", usageLine(usage, colors, { summary: false })];
|
|
415
|
+
return [...head, "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
414
416
|
`);
|
|
415
417
|
}
|
|
416
418
|
function exitRows(exits, colors = paint(process8.stdout)) {
|
|
@@ -556,7 +558,7 @@ function parse(args, usage, options, settings = {}) {
|
|
|
556
558
|
const values = parsed.values;
|
|
557
559
|
applyOutput("color" in output ? values.color : undefined, "plain" in output ? values.plain : undefined);
|
|
558
560
|
if (values.help === true) {
|
|
559
|
-
console.log(wantsHelpJson() ? JSON.stringify(description(usage, settings, listing)) : helpText(usage, listing, undefined, settings));
|
|
561
|
+
console.log(wantsHelpJson() ? JSON.stringify(description(usage, settings, listing)) : helpText(usage, listing, undefined, { ...settings, bin: heading.bin }));
|
|
560
562
|
throw new HelpShown;
|
|
561
563
|
}
|
|
562
564
|
checkChoices(parsed.values, all);
|
|
@@ -693,7 +695,7 @@ function nearestOption(message, options, allowNegative) {
|
|
|
693
695
|
const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
|
|
694
696
|
return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
|
|
695
697
|
}
|
|
696
|
-
var DASHES, EXIT, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
|
|
698
|
+
var DASHES, EXIT, Exit, UsageError, HelpShown, completion, heading, OUTPUT_OPTIONS, UNKNOWN_OPTION;
|
|
697
699
|
var init_args = __esm(() => {
|
|
698
700
|
init_format();
|
|
699
701
|
init_help();
|
|
@@ -728,6 +730,7 @@ var init_args = __esm(() => {
|
|
|
728
730
|
}
|
|
729
731
|
};
|
|
730
732
|
completion = { active: false };
|
|
733
|
+
heading = { bin: undefined };
|
|
731
734
|
OUTPUT_OPTIONS = {
|
|
732
735
|
color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
|
|
733
736
|
plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
|
|
@@ -1533,10 +1536,13 @@ async function runMain({ name, version, run, redact, usage }, argv = scriptArgs(
|
|
|
1533
1536
|
}
|
|
1534
1537
|
let code;
|
|
1535
1538
|
const started = performance.now();
|
|
1539
|
+
heading.bin = { name, version: () => version ?? packageVersion() };
|
|
1536
1540
|
try {
|
|
1537
1541
|
code = await run(argv);
|
|
1538
1542
|
} catch (error) {
|
|
1539
1543
|
code = reportThrown(name, error, redact, wantsJson(argv));
|
|
1544
|
+
} finally {
|
|
1545
|
+
heading.bin = undefined;
|
|
1540
1546
|
}
|
|
1541
1547
|
notifyEnd(name, code, performance.now() - started);
|
|
1542
1548
|
if (usage !== false) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaynooo/cli-pick",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.6",
|
|
5
5
|
"description": "pick: a themed fuzzy selector, lines on stdin, the chosen one on stdout.",
|
|
6
6
|
"author": "Kaynooo <contact@kaynooo.fr>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -35,6 +35,6 @@
|
|
|
35
35
|
"pick": "$npm_execpath src/pick.ts"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@kaynooo/cli-kit": "0.46.
|
|
38
|
+
"@kaynooo/cli-kit": "0.46.5"
|
|
39
39
|
}
|
|
40
40
|
}
|