Skip to content

Commit

Permalink
better type for builder
Browse files Browse the repository at this point in the history
  • Loading branch information
brandenrodgers committed Jan 15, 2025
1 parent cac1307 commit 001438e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
13 changes: 10 additions & 3 deletions commands/account/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@ import { getAccessToken } from '@hubspot/local-dev-lib/personalAccessKey';
import { addConfigOptions } from '../../lib/commonOpts';
import { i18n } from '../../lib/lang';
import { getTableContents } from '../../lib/ui/table';
import { CommonOptions } from '../../types/Yargs';
import { CommonArguments } from '../../types/Yargs';

const i18nKey = 'commands.account.subcommands.info';
export const describe = i18n(`${i18nKey}.describe`);

export const command = 'info [account]';

export async function handler(options: CommonOptions): Promise<void> {
type AccountInfoOptions = {
config?: string;
someNewField: number;
};

export async function handler(
options: CommonArguments<AccountInfoOptions>
): Promise<void> {
const { derivedAccountId } = options;
const config = getAccountConfig(derivedAccountId);
// check if the provided account is using a personal access key, if not, show an error
Expand Down Expand Up @@ -41,7 +48,7 @@ export async function handler(options: CommonOptions): Promise<void> {
}
}

export function builder(yargs: Argv): Argv {
export function builder(yargs: Argv): Argv<AccountInfoOptions> {
addConfigOptions(yargs);

yargs.example([
Expand Down
1 change: 1 addition & 0 deletions commands/doctor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const { i18n } = require('../lib/lang');

export interface DoctorOptions {
'output-dir'?: string;
someNewField: number;
}

const i18nKey = 'commands.doctor';
Expand Down
4 changes: 2 additions & 2 deletions types/Yargs.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Arguments } from 'yargs';
import { ArgumentsCamelCase } from 'yargs';

export type CommonOptions<T = object> = Arguments<
export type CommonArguments<T = object> = ArgumentsCamelCase<
T & {
derivedAccountId: number;
providedAccountId?: number;
Expand Down

0 comments on commit 001438e

Please sign in to comment.