mirror of
https://github.com/swc-project/swc.git
synced 2024-12-21 12:41:54 +03:00
fec189f2f3
bundler: - Prevent stack overflow. (denoland/deno#9752) testing: - Bump version - Fix handling of paths on windows. testing_macros: - Bump version - Correctly ignore files.
33 lines
1.0 KiB
TypeScript
33 lines
1.0 KiB
TypeScript
// Loaded from https://deno.land/x/cliffy@v0.18.0/command/help/mod.ts
|
|
|
|
|
|
import { Command } from "../command.ts";
|
|
import { UnknownCommand } from "../_errors.ts";
|
|
import { CommandType } from "../types/command.ts";
|
|
|
|
/** Generates well formatted and colored help output for specified command. */
|
|
export class HelpCommand extends Command<void, [command?: string]> {
|
|
public constructor(cmd?: Command) {
|
|
super();
|
|
this.type("command", new CommandType())
|
|
.arguments("[command:command]")
|
|
.description("Show this help or the help of a sub-command.")
|
|
.action((_, name?: string) => {
|
|
if (!cmd) {
|
|
cmd = name
|
|
? this.getGlobalParent()?.getBaseCommand(name)
|
|
: this.getGlobalParent();
|
|
}
|
|
if (!cmd) {
|
|
const cmds = this.getGlobalParent()?.getCommands();
|
|
throw new UnknownCommand(name ?? "", cmds ?? [], [
|
|
this.getName(),
|
|
...this.getAliases(),
|
|
]);
|
|
}
|
|
cmd.showHelp();
|
|
Deno.exit(0);
|
|
});
|
|
}
|
|
}
|