You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(cli): fix various minor codegen issues (#32024)
### Reason for this change
Fixes some small issues that got missed before #31850 was unintentionally merged too early.
### Description of changes
* re-add support for `CDK_` env variables
* remove square bracktes when commands don't have an alias
* remove extra space in command args
* fixed `demandCommand` call
### Description of how you validated changes
Run via tests, compared manually with cli options before we started to generate them.
### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)
----
*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Copy file name to clipboardExpand all lines: packages/aws-cdk/lib/parse-command-line-arguments.ts
+54-50
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,7 @@ export function parseCommandLineArguments(
15
15
yargsNegativeAlias: any
16
16
): any{
17
17
returnyargs
18
+
.env('CDK')
18
19
.usage('Usage: cdk -a <cdk-app> COMMAND')
19
20
.option('app',{
20
21
type: 'string',
@@ -148,7 +149,7 @@ export function parseCommandLineArguments(
148
149
desc: 'Opt in to unstable features. The flag indicates that the scope and API of a feature might still change. Otherwise the feature is generally production ready and fully supported. Can be specified multiple times.',
149
150
default: [],
150
151
})
151
-
.command(['list [STACKS..]','ls [STACKS..]'],'Lists all stacks in the app',(yargs: Argv)=>
152
+
.command(['list [STACKS..]','ls [STACKS..]'],'Lists all stacks in the app',(yargs: Argv)=>
152
153
yargs
153
154
.option('long',{
154
155
type: 'boolean',
@@ -163,7 +164,7 @@ export function parseCommandLineArguments(
163
164
desc: 'Display stack dependency information for each stack',
164
165
})
165
166
)
166
-
.command(['synthesize [STACKS..]','synth [STACKS..]'],'Synthesizes and prints the CloudFormation template for this stack',(yargs: Argv)=>
167
+
.command(['synthesize [STACKS..]','synth [STACKS..]'],'Synthesizes and prints the CloudFormation template for this stack',(yargs: Argv)=>
167
168
yargs
168
169
.option('exclusively',{
169
170
type: 'boolean',
@@ -182,7 +183,7 @@ export function parseCommandLineArguments(
182
183
default: false,
183
184
})
184
185
)
185
-
.command(['bootstrap [ENVIRONMENTS..]'],'Deploys the CDK toolkit stack into an AWS environment',(yargs: Argv)=>
186
+
.command('bootstrap [ENVIRONMENTS..]','Deploys the CDK toolkit stack into an AWS environment',(yargs: Argv)=>
186
187
yargs
187
188
.option('bootstrap-bucket-name',{
188
189
type: 'string',
@@ -292,40 +293,43 @@ export function parseCommandLineArguments(
292
293
desc: 'Use previous values for existing parameters (you must specify all parameters on every deployment if this is disabled)',
desc: 'The action (or sub-action) you want to perform. Valid entires are "print", "tag", "delete-tagged", "full".',
304
+
default: 'full',
305
+
})
306
+
.option('type',{
307
+
type: 'string',
308
+
desc: 'Specify either ecr, s3, or all',
309
+
default: 'all',
310
+
})
311
+
.option('rollback-buffer-days',{
312
+
type: 'number',
313
+
desc: 'Delete assets that have been marked as isolated for this many days',
314
+
default: 0,
315
+
})
316
+
.option('created-buffer-days',{
317
+
type: 'number',
318
+
desc: 'Never delete assets younger than this (in days)',
319
+
default: 1,
320
+
})
321
+
.option('confirm',{
322
+
type: 'boolean',
323
+
desc: 'Confirm via manual prompt before deletion',
324
+
default: true,
325
+
})
326
+
.option('bootstrap-stack-name',{
327
+
type: 'string',
328
+
desc: 'The name of the CDK toolkit stack, if different from the default "CDKToolkit"',
329
+
requiresArg: true,
330
+
})
327
331
)
328
-
.command(['deploy [STACKS..]'],'Deploys the stack(s) named STACKS into your AWS account',(yargs: Argv)=>
332
+
.command('deploy [STACKS..]','Deploys the stack(s) named STACKS into your AWS account',(yargs: Argv)=>
329
333
yargs
330
334
.option('all',{
331
335
type: 'boolean',
@@ -459,7 +463,7 @@ export function parseCommandLineArguments(
459
463
default: false,
460
464
})
461
465
)
462
-
.command(['rollback [STACKS..]'],'Rolls back the stack(s) named STACKS to their last stable state',(yargs: Argv)=>
466
+
.command('rollback [STACKS..]','Rolls back the stack(s) named STACKS to their last stable state',(yargs: Argv)=>
463
467
yargs
464
468
.option('all',{
465
469
type: 'boolean',
@@ -488,7 +492,7 @@ export function parseCommandLineArguments(
488
492
default: [],
489
493
})
490
494
)
491
-
.command(['import [STACK]'],'Import existing resource(s) into the given STACK',(yargs: Argv)=>
495
+
.command('import [STACK]','Import existing resource(s) into the given STACK',(yargs: Argv)=>
492
496
yargs
493
497
.option('execute',{
494
498
type: 'boolean',
@@ -526,7 +530,7 @@ export function parseCommandLineArguments(
526
530
desc: 'If specified, CDK will use the given file to map physical resources to CDK resources for import, instead of interactively asking the user. Can be run from scripts',
527
531
})
528
532
)
529
-
.command(['watch [STACKS..]'],"Shortcut for 'deploy --watch'",(yargs: Argv)=>
533
+
.command('watch [STACKS..]',"Shortcut for 'deploy --watch'",(yargs: Argv)=>
530
534
yargs
531
535
.option('build-exclude',{
532
536
type: 'array',
@@ -589,7 +593,7 @@ export function parseCommandLineArguments(
589
593
requiresArg: true,
590
594
})
591
595
)
592
-
.command(['destroy [STACKS..]'],'Destroy the stack(s) named STACKS',(yargs: Argv)=>
596
+
.command('destroy [STACKS..]','Destroy the stack(s) named STACKS',(yargs: Argv)=>
593
597
yargs
594
598
.option('all',{
595
599
type: 'boolean',
@@ -608,7 +612,7 @@ export function parseCommandLineArguments(
608
612
})
609
613
)
610
614
.command(
611
-
['diff [STACKS..]'],
615
+
'diff [STACKS..]',
612
616
'Compares the specified stack with the deployed stack or a local template file, and returns with status 1 if any difference is found',
613
617
(yargs: Argv)=>
614
618
yargs
@@ -660,17 +664,17 @@ export function parseCommandLineArguments(
660
664
default: true,
661
665
})
662
666
)
663
-
.command(['metadata [STACK]'],'Returns all metadata associated with this stack')
664
-
.command(['acknowledge [ID]','ack [ID]'],'Acknowledge a notice so that it does not show up anymore')
665
-
.command(['notices'],'Returns a list of relevant notices',(yargs: Argv)=>
667
+
.command('metadata [STACK]','Returns all metadata associated with this stack')
668
+
.command(['acknowledge [ID]','ack [ID]'],'Acknowledge a notice so that it does not show up anymore')
669
+
.command('notices','Returns a list of relevant notices',(yargs: Argv)=>
666
670
yargs.option('unacknowledged',{
667
671
type: 'boolean',
668
672
alias: 'u',
669
673
default: false,
670
674
desc: 'Returns a list of unacknowledged notices',
671
675
})
672
676
)
673
-
.command(['init [TEMPLATE]'],'Create a new, empty CDK project from a template.',(yargs: Argv)=>
677
+
.command('init [TEMPLATE]','Create a new, empty CDK project from a template.',(yargs: Argv)=>
674
678
yargs
675
679
.option('language',{
676
680
type: 'string',
@@ -688,7 +692,7 @@ export function parseCommandLineArguments(
688
692
desc: 'If true, only generates project files, without executing additional operations such as setting up a git repo, installing dependencies or compiling the project',
689
693
})
690
694
)
691
-
.command(['migrate'],false,(yargs: Argv)=>
695
+
.command('migrate',false,(yargs: Argv)=>
692
696
yargs
693
697
.option('stack-name',{
694
698
type: 'string',
@@ -736,7 +740,7 @@ export function parseCommandLineArguments(
736
740
desc: 'Use this flag to zip the generated CDK app',
0 commit comments