chore: add help alias and enable strict mode

This commit is contained in:
qun 2024-03-01 12:30:22 +00:00
parent db06dd68f4
commit ea7e721a68
3 changed files with 22 additions and 5 deletions
apps/sparo-lib/src
cli/commands
services
common/changes/sparo

View file

@ -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 '';
}

View file

@ -25,6 +25,8 @@ export class ArgvService {
// --verbose
.boolean('verbose')
.middleware([this._terminalMiddleware])
.alias('help', 'h')
.strict()
.parseAsync();
}

View file

@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "sparo",
"comment": "Add help alias and enable strict mode",
"type": "none"
}
],
"packageName": "sparo"
}