mirror of
https://github.com/tiktok/sparo.git
synced 2025-03-27 05:11:42 -04:00
feat: show help text
This commit is contained in:
parent
fe6e9ac69b
commit
b1d04a9780
8 changed files with 37 additions and 26 deletions
apps/sparo-lib/src
|
@ -56,9 +56,17 @@ export class CheckoutCommand implements ICommand<ICheckoutCommandOptions> {
|
|||
.positional('start-point', {
|
||||
type: 'string'
|
||||
})
|
||||
.boolean('b')
|
||||
.string('branch')
|
||||
.string('startPoint')
|
||||
.option('b', {
|
||||
type: 'boolean',
|
||||
description: 'Create a new branch and start it at <start-point>'
|
||||
})
|
||||
.option('B', {
|
||||
type: 'boolean',
|
||||
description:
|
||||
'Create a new branch and start it at <start-point>; if it already exists, reset it to <start-point>'
|
||||
})
|
||||
.array('profile')
|
||||
.default('profile', [])
|
||||
.array('add-profile')
|
||||
|
|
|
@ -12,7 +12,9 @@ export class GitCheckoutCommand implements ICommand<{}> {
|
|||
public description: string = 'original git checkout command';
|
||||
@inject(GitService) private _gitService!: GitService;
|
||||
|
||||
public builder(yargs: Argv<{}>): void {}
|
||||
public builder(yargs: Argv<{}>): void {
|
||||
yargs.help(false);
|
||||
}
|
||||
|
||||
public handler = async (args: ArgumentsCamelCase<{}>, terminalService: TerminalService): Promise<void> => {
|
||||
const { _gitService: gitService } = this;
|
||||
|
|
|
@ -12,7 +12,9 @@ export class GitCloneCommand implements ICommand<{}> {
|
|||
public description: string = 'original git clone command';
|
||||
@inject(GitService) private _gitService!: GitService;
|
||||
|
||||
public builder(yargs: Argv<{}>): void {}
|
||||
public builder(yargs: Argv<{}>): void {
|
||||
yargs.help(false);
|
||||
}
|
||||
|
||||
public handler = async (args: ArgumentsCamelCase<{}>, terminalService: TerminalService): Promise<void> => {
|
||||
const { _gitService: gitService } = this;
|
||||
|
|
|
@ -13,7 +13,9 @@ export class GitFetchCommand implements ICommand<{}> {
|
|||
|
||||
@inject(GitService) public _gitService!: GitService;
|
||||
|
||||
public builder(yargs: Argv<{}>): void {}
|
||||
public builder(yargs: Argv<{}>): void {
|
||||
yargs.help(false);
|
||||
}
|
||||
|
||||
public handler = async (args: ArgumentsCamelCase<{}>, terminalService: TerminalService): Promise<void> => {
|
||||
const { _gitService: gitService } = this;
|
||||
|
|
|
@ -11,7 +11,11 @@ export class GitPullCommand implements ICommand<{}> {
|
|||
public cmd: string = 'git-pull';
|
||||
public description: string = 'original git pull command';
|
||||
@inject(GitService) public _gitService!: GitService;
|
||||
public builder(yargs: Argv<{}>): void {}
|
||||
|
||||
public builder(yargs: Argv<{}>): void {
|
||||
yargs.help(false);
|
||||
}
|
||||
|
||||
public handler = async (args: ArgumentsCamelCase<{}>, terminalService: TerminalService): Promise<void> => {
|
||||
const { _gitService: gitService } = this;
|
||||
const { terminal } = terminalService;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Command } from '../../decorator';
|
||||
import { Argv } from 'yargs';
|
||||
import type { Argv } from 'yargs';
|
||||
import type { ICommand } from './base';
|
||||
|
||||
export interface IHelpCommandOptions {}
|
||||
|
@ -8,22 +8,14 @@ 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 {
|
||||
yargs.command(
|
||||
'commands',
|
||||
'commands',
|
||||
() => {},
|
||||
() => {
|
||||
console.log('command help');
|
||||
}
|
||||
);
|
||||
}
|
||||
public async handler(): Promise<void> {
|
||||
console.log(`Sparo
|
||||
usage: sparo COMMAND [OPTIONS]
|
||||
`);
|
||||
}
|
||||
public builder = (yargs: Argv<IHelpCommandOptions>): void => {
|
||||
this._yargs = yargs;
|
||||
};
|
||||
public handler = async (): Promise<void> => {
|
||||
this._yargs?.showHelp();
|
||||
};
|
||||
public getHelp(): string {
|
||||
return '';
|
||||
}
|
||||
|
|
|
@ -18,14 +18,16 @@ export class InitProfileCommand implements ICommand<IInitProjectCommandOptions>
|
|||
public cmd: string = 'init-profile';
|
||||
public description: string = 'Initialize a new profile.';
|
||||
|
||||
// template section name --> whether it should be commented out
|
||||
private _commentedBySectionName: Map<string, boolean> = new Map<string, boolean>();
|
||||
|
||||
@inject(SparoProfileService) private _sparoProfileService!: SparoProfileService;
|
||||
@inject(TerminalService) private _terminalService!: TerminalService;
|
||||
|
||||
public builder(yargs: Argv<IInitProjectCommandOptions>): void {
|
||||
yargs.string('profile').demandOption(['profile']);
|
||||
yargs
|
||||
.option('profile', {
|
||||
type: 'string',
|
||||
description: 'The name of the profile to initialize.'
|
||||
})
|
||||
.demandOption(['profile']);
|
||||
}
|
||||
|
||||
public handler = async (
|
||||
|
|
|
@ -20,7 +20,6 @@ export class ArgvService {
|
|||
|
||||
public async parseArgvAsync(): Promise<void> {
|
||||
this._parsed = await this.yargsArgv
|
||||
.help(false)
|
||||
// --debug
|
||||
.boolean('debug')
|
||||
// --verbose
|
||||
|
|
Loading…
Add table
Reference in a new issue