Skip to content

Commit 78fba23

Browse files
authored
chore(cli): rename _ to command in UserInput (#32822)
This does not change CLI functionality because `UserInput` is not in use yet. Since we have full control over `UserInput`, i.e. we control the input functions from the CLI or `cdk.json`, we can rename properties however we like. `_` is a relic of `yargs`, we do not need to maintain that convention. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 62ae02e commit 78fba23

File tree

7 files changed

+11
-11
lines changed

7 files changed

+11
-11
lines changed

packages/aws-cdk/lib/convert-to-user-input.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ export function convertYargsToUserInput(args: any): UserInput {
251251
break;
252252
}
253253
const userInput: UserInput = {
254-
_: args._[0],
254+
command: args._[0],
255255
globalOptions,
256256
[args._[0]]: commandOptions,
257257
};

packages/aws-cdk/lib/user-input.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export interface UserInput {
1414
/**
1515
* The CLI command name
1616
*/
17-
readonly _?: Command;
17+
readonly command?: Command;
1818

1919
/**
2020
* Global options available to all CLI commands

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe('yargs', () => {
88
const result = convertYargsToUserInput(input);
99

1010
expect(result).toEqual({
11-
_: 'deploy',
11+
command: 'deploy',
1212
globalOptions: {
1313
app: undefined,
1414
assetMetadata: undefined,
@@ -73,7 +73,7 @@ describe('yargs', () => {
7373
const result = convertYargsToUserInput(input);
7474

7575
expect(result).toEqual({
76-
_: 'deploy',
76+
command: 'deploy',
7777
deploy: expect.objectContaining({
7878
STACKS: ['stack1', 'stack2'],
7979
}),
@@ -87,7 +87,7 @@ describe('yargs', () => {
8787
const result = convertYargsToUserInput(input);
8888

8989
expect(result).toEqual({
90-
_: 'acknowledge',
90+
command: 'acknowledge',
9191
acknowledge: expect.objectContaining({
9292
ID: 'id1',
9393
}),

tools/@aws-cdk/user-input-gen/lib/convert-to-user-input-gen.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ function buildPositionalArguments(arg: { name: string; variadic: boolean }, argN
142142
function buildUserInput(argName: string): string {
143143
return [
144144
'const userInput: UserInput = {',
145-
`_: ${argName}._[0],`,
145+
`command: ${argName}._[0],`,
146146
'globalOptions,',
147147
`[${argName}._[0]]: commandOptions`,
148148
'}',

tools/@aws-cdk/user-input-gen/lib/user-input-gen.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export async function renderUserInputType(config: CliConfig): Promise<string> {
2525
const commandEnum = Type.fromName(scope, 'Command');
2626

2727
userInputType.addProperty({
28-
name: '_',
28+
name: 'command',
2929
type: commandEnum,
3030
docs: {
3131
summary: 'The CLI command name',

tools/@aws-cdk/user-input-gen/test/convert-to-user-input-gen.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ describe('render', () => {
7171
break;
7272
}
7373
const userInput: UserInput = {
74-
_: args._[0],
74+
command: args._[0],
7575
globalOptions,
7676
[args._[0]]: commandOptions,
7777
};

tools/@aws-cdk/user-input-gen/test/user-input-gen.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ describe('render', () => {
6060
/**
6161
* The CLI command name
6262
*/
63-
readonly _?: Command;
63+
readonly command?: Command;
6464
6565
/**
6666
* Global options available to all CLI commands
@@ -169,7 +169,7 @@ describe('render', () => {
169169
/**
170170
* The CLI command name
171171
*/
172-
readonly _?: Command;
172+
readonly command?: Command;
173173
174174
/**
175175
* Global options available to all CLI commands
@@ -251,7 +251,7 @@ describe('render', () => {
251251
/**
252252
* The CLI command name
253253
*/
254-
readonly _?: Command;
254+
readonly command?: Command;
255255
256256
/**
257257
* Global options available to all CLI commands

0 commit comments

Comments
 (0)