Skip to content

Commit ac3ffa5

Browse files
authored
chore(cli): cli arguments with "count: true" are generated as number types (#32758)
Our cli config has the following for `verbose`: `type: boolean, count: true`. That should be a `number` type, but it currently is a `boolean` type. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent db345c5 commit ac3ffa5

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

packages/aws-cdk/lib/cli-arguments.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export interface GlobalOptions {
194194
*
195195
* @default - false
196196
*/
197-
readonly verbose?: boolean;
197+
readonly verbose?: number;
198198

199199
/**
200200
* Debug the CDK app. Log additional information during synthesis, such as creation stack traces of tokens (sets CDK_DEBUG, will slow down synthesis)

tools/@aws-cdk/cli-args-gen/lib/cli-args-gen.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export async function renderCliArgsType(config: CliConfig): Promise<string> {
4343
for (const [optionName, option] of Object.entries(config.globalOptions)) {
4444
globalOptionType.addProperty({
4545
name: kebabToCamelCase(optionName),
46-
type: convertType(option.type),
46+
type: convertType(option.type, option.count),
4747
docs: {
4848
default: normalizeDefault(option.default, option.type),
4949
summary: option.desc,
@@ -77,7 +77,7 @@ export async function renderCliArgsType(config: CliConfig): Promise<string> {
7777
for (const [optionName, option] of Object.entries(command.options ?? {})) {
7878
commandType.addProperty({
7979
name: kebabToCamelCase(optionName),
80-
type: convertType(option.type),
80+
type: convertType(option.type, option.count),
8181
docs: {
8282
// Notification Arns is a special property where undefined and [] mean different things
8383
default: optionName === 'notification-arns' ? 'undefined' : normalizeDefault(option.default, option.type),
@@ -124,10 +124,10 @@ export async function renderCliArgsType(config: CliConfig): Promise<string> {
124124
});
125125
}
126126

127-
function convertType(type: 'string' | 'array' | 'number' | 'boolean' | 'count'): Type {
127+
function convertType(type: 'string' | 'array' | 'number' | 'boolean' | 'count', count?: boolean): Type {
128128
switch (type) {
129129
case 'boolean':
130-
return Type.BOOLEAN;
130+
return count ? Type.NUMBER : Type.BOOLEAN;
131131
case 'string':
132132
return Type.STRING;
133133
case 'number':

tools/@aws-cdk/cli-args-gen/test/cli-args-gen.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ describe('render', () => {
1313
desc: 'Enable debug logging',
1414
default: false,
1515
},
16+
verbose: {
17+
type: 'boolean',
18+
count: true,
19+
desc: 'Increase logging verbosity',
20+
},
1621
context: {
1722
default: [],
1823
type: 'array',
@@ -88,6 +93,13 @@ describe('render', () => {
8893
*/
8994
readonly debug?: boolean;
9095
96+
/**
97+
* Increase logging verbosity
98+
*
99+
* @default - undefined
100+
*/
101+
readonly verbose?: number;
102+
91103
/**
92104
* context values
93105
*

0 commit comments

Comments
 (0)