Skip to content

[Feature Request] Need a onCancel property #54

Closed

Description

@AkaraChen

Is your feature request related to a problem? Please describe.

I think have a onCancel property will be better.

Currently I need to call isCanceled in every prompts, I think it is troublesome.

Describe the solution you'd like

import { text, cancel } from '@clack/prompts'

const result = await text({
	/* Other options */
	onCancel() {
		cancel('Operation canceled.')
		process.exit(1)
	}
})

Activity

  1. added
    enhancement
    on Feb 17, 2023
  2. cpreston321 commented on Feb 17, 2023

    @cpreston321
    Collaborator

    Hey @AkaraChen until there is a definite solution within core then we can't add these options per prompt without duplication. In the meantime you can wrap within a the new 'group' function and within the second param you pass onCancel like you have above.

    Example here: https://github.com/natemoo-re/clack/blob/main/examples/basic/index.ts

  3. AkaraChen commented on Feb 17, 2023

    @AkaraChen
    Author

    Thanks for such a quick reply.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions