From 7f82c95525a7619b5baadca6cfc1bd0f98213244 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E8=B1=AA?= <504595380@qq.com> Date: Wed, 2 Nov 2022 10:56:34 +0800 Subject: [PATCH] fix(cli): support help command (#1355) --- cli/src/help.ts | 13 +++++++++++++ cli/src/index.ts | 2 ++ 2 files changed, 15 insertions(+) create mode 100644 cli/src/help.ts diff --git a/cli/src/help.ts b/cli/src/help.ts new file mode 100644 index 00000000..18e5cd42 --- /dev/null +++ b/cli/src/help.ts @@ -0,0 +1,13 @@ +import { Command } from 'clipanion' + +/** + * A command that prints the usage of all commands. + * + * Paths: `-h`, `--help` + */ +export class HelpCommand extends Command { + static paths = [[`-h`], [`--help`]] + async execute() { + await this.context.stdout.write(this.cli.usage()) + } +} diff --git a/cli/src/index.ts b/cli/src/index.ts index f810745a..d4cd6c80 100644 --- a/cli/src/index.ts +++ b/cli/src/index.ts @@ -7,6 +7,7 @@ import { version } from '../package.json' import { ArtifactsCommand } from './artifacts' import { BuildCommand } from './build' import { CreateNpmDirCommand } from './create-npm-dir' +import { HelpCommand } from './help' import { NewProjectCommand } from './new' import { PrePublishCommand } from './pre-publish' import { RenameCommand } from './rename' @@ -24,6 +25,7 @@ cli.register(PrePublishCommand) cli.register(VersionCommand) cli.register(NewProjectCommand) cli.register(RenameCommand) +cli.register(HelpCommand) cli .run(process.argv.slice(2), {