mirror of
https://github.com/tiktok/sparo.git
synced 2025-03-25 20:29:50 -04:00
chore: add help alias and enable strict mode
This commit is contained in:
parent
db06dd68f4
commit
ea7e721a68
3 changed files with 22 additions and 5 deletions
apps/sparo-lib/src
common/changes/sparo
|
@ -1,6 +1,8 @@
|
|||
import { Command } from '../../decorator';
|
||||
import type { Argv } from 'yargs';
|
||||
import type { ICommand } from './base';
|
||||
import { ArgvService } from '../../services/ArgvService';
|
||||
import { inject } from 'inversify';
|
||||
|
||||
export interface IHelpCommandOptions {}
|
||||
|
||||
|
@ -8,14 +10,17 @@ export interface IHelpCommandOptions {}
|
|||
export class HelpCommand implements ICommand<IHelpCommandOptions> {
|
||||
public cmd: string = 'help';
|
||||
public description: string = '';
|
||||
private _yargs: Argv<IHelpCommandOptions> | undefined;
|
||||
|
||||
public builder = (yargs: Argv<IHelpCommandOptions>): void => {
|
||||
this._yargs = yargs;
|
||||
};
|
||||
@inject(ArgvService) private _yargs!: ArgvService;
|
||||
|
||||
public builder(yargs: Argv<{}>): void {
|
||||
yargs.help(false);
|
||||
}
|
||||
|
||||
public handler = async (): Promise<void> => {
|
||||
this._yargs?.showHelp();
|
||||
this._yargs.yargsArgv.showHelp();
|
||||
};
|
||||
|
||||
public getHelp(): string {
|
||||
return '';
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ export class ArgvService {
|
|||
// --verbose
|
||||
.boolean('verbose')
|
||||
.middleware([this._terminalMiddleware])
|
||||
.alias('help', 'h')
|
||||
.strict()
|
||||
.parseAsync();
|
||||
}
|
||||
|
||||
|
|
10
common/changes/sparo/main_2024-03-01-12-30.json
Normal file
10
common/changes/sparo/main_2024-03-01-12-30.json
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"changes": [
|
||||
{
|
||||
"packageName": "sparo",
|
||||
"comment": "Add help alias and enable strict mode",
|
||||
"type": "none"
|
||||
}
|
||||
],
|
||||
"packageName": "sparo"
|
||||
}
|
Loading…
Add table
Reference in a new issue