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

feat(prompt): configurable cancel strategy #325

Merged
merged 4 commits into from
Dec 19, 2024
Merged

feat(prompt): configurable cancel strategy #325

merged 4 commits into from
Dec 19, 2024

Conversation

pi0
Copy link
Member

@pi0 pi0 commented Dec 19, 2024

Resolves #234 #251

When prompts get canceled by user Ctrl+C it was returning (untyped/undocumented) Symbol(clack:cancel).

This PR adds a new cancel option to specify strategy:

  • "default" - Resolve the promise with the default value or initial value.
  • "undefined" - Resolve the promise with undefined.
  • "null" - Resolve the promise with null.
  • "symbol" - Resolve the promise with a symbol Symbol.for("cancel").
  • "reject" - Reject the promise with an error.

Default is set to "default" a small behavior change from current that returns the internal Clack symbol to keep backward compatibility with (expected) typed behavior.

Possible canceled return type is added

@pi0 pi0 merged commit faa9cbd into main Dec 19, 2024
2 checks passed
@pi0 pi0 deleted the fix/prompt-cancel branch December 19, 2024 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

typescript: prompt could return Symbol('clack:cancel')
1 participant