fix(cli): make 'kilo help' show same output as 'kilo -h'

This commit is contained in:
Alex Alecu
2026-04-08 13:57:25 +03:00
parent 8327300881
commit fb5d85e2e5
2 changed files with 46 additions and 35 deletions
+5 -2
View File
@@ -54,7 +54,7 @@ import { Auth } from "./auth"
import { DbCommand } from "./cli/cmd/db"
import path from "path"
import { Global } from "./global"
import { HelpCommand } from "./kilocode/help-command" // kilocode_change
import { createHelpCommand } from "./kilocode/help-command" // kilocode_change
import { JsonMigration } from "./storage/json-migration"
import { Database } from "./storage/db"
@@ -197,9 +197,12 @@ let cli = yargs(hideBin(process.argv))
.command(SessionCommand)
.command(RemoteCommand) // kilocode_change
.command(DbCommand)
.command(HelpCommand) // kilocode_change
.command(ConfigCLICommand) // kilocode_change
// kilocode_change start - registered after initial chain to avoid self-referential type error
cli = cli.command(createHelpCommand(() => cli))
// kilocode_change end
if (Installation.isLocal()) {
cli = cli.command(WorkspaceServeCommand)
}
+41 -33
View File
@@ -1,37 +1,45 @@
import { cmd } from "../cli/cmd/cmd"
import { generateHelp } from "./help"
import type { Argv } from "yargs"
export const HelpCommand = cmd({
command: "help [command]",
describe: "show full CLI reference",
builder: (yargs) =>
yargs
.positional("command", {
describe: "command to show help for",
type: "string",
export function createHelpCommand(root?: () => Argv) {
return cmd({
command: "help [command]",
describe: "show full CLI reference",
builder: (yargs) =>
yargs
.positional("command", {
describe: "command to show help for",
type: "string",
})
.option("all", {
describe: "show help for all commands",
type: "boolean",
default: false,
})
.option("format", {
describe: "output format",
type: "string",
choices: ["md", "text"] as const,
default: "md" as const,
}),
async handler(args) {
if (!args.command && !args.all) {
if (root) {
const help = await root().getHelp()
process.stdout.write(help + "\n")
}
return
}
const output = await generateHelp({
command: args.command,
all: args.all,
format: args.format as "md" | "text",
})
.option("all", {
describe: "show help for all commands",
type: "boolean",
default: false,
})
.option("format", {
describe: "output format",
type: "string",
choices: ["md", "text"] as const,
default: "md" as const,
}),
async handler(args) {
if (!args.command && !args.all) {
process.stdout.write("Usage: kilo help --all Show full CLI reference\n")
process.stdout.write(" kilo help <command> Show help for a specific command\n")
return
}
const output = await generateHelp({
command: args.command,
all: args.all,
format: args.format as "md" | "text",
})
process.stdout.write(output + "\n")
},
})
process.stdout.write(output + "\n")
},
})
}
// Static instance for introspection by commands.ts / help.ts (handler not invoked)
export const HelpCommand = createHelpCommand()