fix(cli): support help command (#1355)

This commit is contained in:
阿豪 2022-11-02 10:56:34 +08:00 committed by GitHub
parent b5cfa93789
commit 7f82c95525
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

13
cli/src/help.ts Normal file
View file

@ -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<any> {
static paths = [[`-h`], [`--help`]]
async execute() {
await this.context.stdout.write(this.cli.usage())
}
}

View file

@ -7,6 +7,7 @@ import { version } from '../package.json'
import { ArtifactsCommand } from './artifacts' import { ArtifactsCommand } from './artifacts'
import { BuildCommand } from './build' import { BuildCommand } from './build'
import { CreateNpmDirCommand } from './create-npm-dir' import { CreateNpmDirCommand } from './create-npm-dir'
import { HelpCommand } from './help'
import { NewProjectCommand } from './new' import { NewProjectCommand } from './new'
import { PrePublishCommand } from './pre-publish' import { PrePublishCommand } from './pre-publish'
import { RenameCommand } from './rename' import { RenameCommand } from './rename'
@ -24,6 +25,7 @@ cli.register(PrePublishCommand)
cli.register(VersionCommand) cli.register(VersionCommand)
cli.register(NewProjectCommand) cli.register(NewProjectCommand)
cli.register(RenameCommand) cli.register(RenameCommand)
cli.register(HelpCommand)
cli cli
.run(process.argv.slice(2), { .run(process.argv.slice(2), {