Skip to content

Commit

Permalink
fix(cli): support help command (#1355)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahaoboy committed Nov 2, 2022
1 parent b5cfa93 commit 7f82c95
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions 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<any> {
static paths = [[`-h`], [`--help`]]
async execute() {
await this.context.stdout.write(this.cli.usage())
}
}
2 changes: 2 additions & 0 deletions cli/src/index.ts
Expand Up @@ -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'
Expand All @@ -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), {
Expand Down

0 comments on commit 7f82c95

Please sign in to comment.