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

Improve spinner's cancel messages #209

Open
luiguild opened this issue Nov 20, 2024 · 1 comment
Open

Improve spinner's cancel messages #209

luiguild opened this issue Nov 20, 2024 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@luiguild
Copy link

const msg = code > 1 ? 'Something went wrong' : 'Canceled';

Hello, first of all, thank you for your lib, I've been use it for a while now, and I really want to help you to improve it if it's the case.

I want to find a way to change some behaviors, in this particular case I want to have better cancel messages. The reason for this is that my CLI is multilingual, and these messages end up breaking my flow. All other messages I can customize without issues or, at the very least, intercept the flow to rewrite the output in the terminal.

I believe a good way to work around this would be to capture the spinner’s exit event using the isCancel method, just as we can do with prompts. I understand that the method’s purpose is different for prompts, but I believe this approach would maintain the library’s consistency.

Another idea could be to allow passing this message to the constructor when we instantiate the spinner.

I’m open to helping and submitting a PR with these modifications, but I’d like to know your opinion on this. How do you see this situation?

Once again, thank you.

@natemoo-re
Copy link
Member

natemoo-re commented Jan 4, 2025

Hey, thanks for opening an issue! I think it would be great to expose more control here for multilingual use cases—seems like a relatively small feature!

Maybe this could be handled similarly to the updateSettings function exposed from @clack/core? Basically just a global object that users can write to before calling the prompts.

export interface ClackSettings {
/**
* Set custom global aliases for the default actions.
* This will not overwrite existing aliases, it will only add new ones!
*
* @param aliases - An object that maps aliases to actions
* @default { k: 'up', j: 'down', h: 'left', l: 'right', '\x03': 'cancel', 'escape': 'cancel' }
*/
aliases: Record<string, Action>;
}
export function updateSettings(updates: ClackSettings) {

@natemoo-re natemoo-re moved this from Needs triage to Backlog in Triage Board Jan 4, 2025
@natemoo-re natemoo-re moved this from Backlog to On deck in Triage Board Jan 4, 2025
@natemoo-re natemoo-re added enhancement New feature or request good first issue Good for newcomers labels Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
Status: On deck
Development

No branches or pull requests

2 participants