Skip to content

Conversation

@ren-yamanashi
Copy link
Contributor

@ren-yamanashi ren-yamanashi commented Aug 29, 2025

Fixes #732

Added --yes cli option so that if true, the command is always executed without confirmation.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added the p2 label Aug 29, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team August 29, 2025 13:31
@ren-yamanashi ren-yamanashi changed the title feat(cli): add non-interactive mode support to CLI feat(cli): add --yes flag Aug 29, 2025
@codecov-commenter
Copy link

codecov-commenter commented Aug 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.57%. Comparing base (a890d3f) to head (cf7a224).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #826      +/-   ##
==========================================
+ Coverage   82.92%   83.57%   +0.65%     
==========================================
  Files          65       65              
  Lines        9528     9546      +18     
  Branches     1120     1141      +21     
==========================================
+ Hits         7901     7978      +77     
+ Misses       1605     1543      -62     
- Partials       22       25       +3     
Flag Coverage Δ
suite.unit 83.57% <100.00%> (+0.65%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines +437 to +441
// In non-interactive mode, always return success (true).
if (this.nonInteractive) {
return true;
}

Copy link
Contributor Author

@ren-yamanashi ren-yamanashi Aug 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q. It should return msg.defaultResponse instead of true?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we need to return true for isConfirmationPrompt, msg.defaultResponse if there is one, and continue otherwise.

I would also like us to still print the question and answer and indicating that --yes was used.

We should also only do this after the this.skipApprovalStep(msg) check. On the other hand, --yes should make scenarios work where we don't have a TTY or are using concurrency. So we will need to restructure the checks.

Copy link
Contributor

@mrgrain mrgrain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two existing uses of promptly that should be changed over as well as part of this:

const confirmed = await promptly.confirm(

const confirmed = await promptly.confirm(`${chalk.cyan(question)} (y/n)?`);

Refactor should be a confirm:

const response = await ioHelper.requestResponse(IO.CDK_TOOLKIT_I8910.req(question, {
responseDescription: '[Y]es/[n]o',
}, 'y'));
return ['y', 'yes'].includes(response.toLowerCase());

Comment on lines +437 to +441
// In non-interactive mode, always return success (true).
if (this.nonInteractive) {
return true;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we need to return true for isConfirmationPrompt, msg.defaultResponse if there is one, and continue otherwise.

I would also like us to still print the question and answer and indicating that --yes was used.

We should also only do this after the this.skipApprovalStep(msg) check. On the other hand, --yes should make scenarios work where we don't have a TTY or are using concurrency. So we will need to restructure the checks.

github-merge-queue bot pushed a commit that referenced this pull request Oct 6, 2025
…rmationRequest interface (#904)

This PR standardizes user confirmation flows across the CDK CLI by
migrating from ad-hoc `promptly.confirm` usage to the structured
`ConfirmationRequest` interface.

These are the changes as suggested here:
#826 (review)

## Changes

- **Convert CDK_TOOLKIT_I8910**: Changed from `DataRequest` to
`ConfirmationRequest` for refactor confirmation
- **Standardize destroy flow**: Replace `promptly.confirm` with
`IO.CDK_TOOLKIT_I7010` message
- **Standardize deploy flow**: Update `askUserConfirmation` to use
`ActionLessRequest<ConfirmationRequest>` pattern
- **Clean up test infrastructure**: Remove deprecated `markTesting`
function and `TESTING` variable
- **Update tests**: Replace `promptly` mocks with `requestSpy` for
consistency

## Benefits

- Consistent user interaction patterns across all CLI commands
- Better testability through standardized mocking
- Improved error handling and TTY detection through the IO system
- Cleaner separation of concerns between UI logic and business logic

---
By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license
iankhou pushed a commit that referenced this pull request Oct 7, 2025
…rmationRequest interface (#904)

This PR standardizes user confirmation flows across the CDK CLI by
migrating from ad-hoc `promptly.confirm` usage to the structured
`ConfirmationRequest` interface.

These are the changes as suggested here:
#826 (review)

## Changes

- **Convert CDK_TOOLKIT_I8910**: Changed from `DataRequest` to
`ConfirmationRequest` for refactor confirmation
- **Standardize destroy flow**: Replace `promptly.confirm` with
`IO.CDK_TOOLKIT_I7010` message
- **Standardize deploy flow**: Update `askUserConfirmation` to use
`ActionLessRequest<ConfirmationRequest>` pattern
- **Clean up test infrastructure**: Remove deprecated `markTesting`
function and `TESTING` variable
- **Update tests**: Replace `promptly` mocks with `requestSpy` for
consistency

## Benefits

- Consistent user interaction patterns across all CLI commands
- Better testability through standardized mocking
- Improved error handling and TTY detection through the IO system
- Cleaner separation of concerns between UI logic and business logic

---
By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license
@mrgrain
Copy link
Contributor

mrgrain commented Oct 7, 2025

Two existing uses of promptly that should be changed over as well as part of this:

const confirmed = await promptly.confirm(

const confirmed = await promptly.confirm(`${chalk.cyan(question)} (y/n)?`);

Refactor should be a confirm:

const response = await ioHelper.requestResponse(IO.CDK_TOOLKIT_I8910.req(question, {
responseDescription: '[Y]es/[n]o',
}, 'y'));
return ['y', 'yes'].includes(response.toLowerCase());

I went ahead and made these unrelated changes in: #904

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(cli): --yes flag

3 participants