@kaynooo/cli-kit 0.17.0 → 0.18.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/package.json +1 -1
- package/src/cli.ts +10 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaynooo/cli-kit",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.18.0",
|
|
5
5
|
"description": "What every @kaynooo CLI shares: argument parsing with --help, a command dispatcher with typo hints and shell completion, and output formatting.",
|
|
6
6
|
"author": "Kaynooo <contact@kaynooo.fr>",
|
|
7
7
|
"license": "MIT",
|
package/src/cli.ts
CHANGED
|
@@ -395,8 +395,16 @@ async function candidates(scope: Scope, defaultCommand: string | undefined, word
|
|
|
395
395
|
command = commands[aliases?.[word] ?? word]
|
|
396
396
|
}
|
|
397
397
|
|
|
398
|
-
if (listing)
|
|
399
|
-
|
|
398
|
+
if (listing) {
|
|
399
|
+
const own = await Promise.all(Object.entries(shown(commands)).map(async ([name, { summary }]) => `${name}\t${await resolveSummary(summary)}`))
|
|
400
|
+
const fallback = defaultCommand === undefined ? undefined : commands[defaultCommand]
|
|
401
|
+
// What the default command takes as its first positional is typed here too, `athome <project>`; a name a command already has is left out.
|
|
402
|
+
const values = fallback !== undefined && 'run' in fallback ? await leafCandidates(fallback.run, [word]) : []
|
|
403
|
+
|
|
404
|
+
const valueOf = (line: string) => line.slice(0, line.includes('\t') ? line.indexOf('\t') : undefined)
|
|
405
|
+
|
|
406
|
+
return [...own, ...values.filter(line => line !== FILES && !(valueOf(line) in commands))]
|
|
407
|
+
}
|
|
400
408
|
|
|
401
409
|
if (command === undefined) {
|
|
402
410
|
const fallback = defaultCommand === undefined ? undefined : commands[defaultCommand]
|