Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(cli): cli arguments with "count: true" are generated as number types #32758

Merged
merged 2 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/aws-cdk/lib/cli-arguments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export interface GlobalOptions {
*
* @default - false
*/
readonly verbose?: boolean;
readonly verbose?: number;

/**
* Debug the CDK app. Log additional information during synthesis, such as creation stack traces of tokens (sets CDK_DEBUG, will slow down synthesis)
Expand Down
8 changes: 4 additions & 4 deletions tools/@aws-cdk/cli-args-gen/lib/cli-args-gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export async function renderCliArgsType(config: CliConfig): Promise<string> {
for (const [optionName, option] of Object.entries(config.globalOptions)) {
globalOptionType.addProperty({
name: kebabToCamelCase(optionName),
type: convertType(option.type),
type: convertType(option.type, option.count),
docs: {
default: normalizeDefault(option.default, option.type),
summary: option.desc,
Expand Down Expand Up @@ -77,7 +77,7 @@ export async function renderCliArgsType(config: CliConfig): Promise<string> {
for (const [optionName, option] of Object.entries(command.options ?? {})) {
commandType.addProperty({
name: kebabToCamelCase(optionName),
type: convertType(option.type),
type: convertType(option.type, option.count),
docs: {
// Notification Arns is a special property where undefined and [] mean different things
default: optionName === 'notification-arns' ? 'undefined' : normalizeDefault(option.default, option.type),
Expand Down Expand Up @@ -124,10 +124,10 @@ export async function renderCliArgsType(config: CliConfig): Promise<string> {
});
}

function convertType(type: 'string' | 'array' | 'number' | 'boolean' | 'count'): Type {
function convertType(type: 'string' | 'array' | 'number' | 'boolean' | 'count', count?: boolean): Type {
switch (type) {
case 'boolean':
return Type.BOOLEAN;
return count ? Type.NUMBER : Type.BOOLEAN;
case 'string':
return Type.STRING;
case 'number':
Expand Down
12 changes: 12 additions & 0 deletions tools/@aws-cdk/cli-args-gen/test/cli-args-gen.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ describe('render', () => {
desc: 'Enable debug logging',
default: false,
},
verbose: {
type: 'boolean',
count: true,
desc: 'Increase logging verbosity',
},
context: {
default: [],
type: 'array',
Expand Down Expand Up @@ -88,6 +93,13 @@ describe('render', () => {
*/
readonly debug?: boolean;

/**
* Increase logging verbosity
*
* @default - undefined
*/
readonly verbose?: number;

/**
* context values
*
Expand Down
Loading