mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-24 16:02:55 +08:00
fix(cli): make 'kilo help' show same output as 'kilo -h'
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user