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

[Request] Grouped spinners? #152

Open
JoshuaKGoldberg opened this issue Aug 26, 2023 · 3 comments · Fixed by #154
Open

[Request] Grouped spinners? #152

JoshuaKGoldberg opened this issue Aug 26, 2023 · 3 comments · Fixed by #154
Labels
enhancement New feature or request

Comments

@JoshuaKGoldberg
Copy link
Collaborator

JoshuaKGoldberg commented Aug 26, 2023

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

Grouping (https://github.com/natemoo-re/clack/tree/24a3f4a20019c7dad2f69bcf163a8b5a3f747a16/packages/prompts#grouping) is available right now for prompts, but not for spinners. But I'd like to group the spinners together too: having a parent task and sub-task.

Describe the solution you'd like

Could we add a new spinner API analogous to p.group? Maybe, p.spinnerGroup?

await p.spinnerGroup("Outer group", [
  ["First sub-task", async () => { /* ... */ }],
  ["Second sub-task", async () => { /* ... */ }],
  ["Third sub-task", async () => { /* ... */ }],
]);

Describe alternatives you've considered

In JoshuaKGoldberg/create-typescript-app#708 -> JoshuaKGoldberg/create-typescript-app#710 I kind of did it manually, wrapping around Clack. It's not great.

Screen.Recording.2023-08-26.at.2.17.08.PM.mov

Additional context

I'd be happy to contribute this, or if you don't want to keep it as a core feature, publish it as a standalone helper package.

@JoshuaKGoldberg JoshuaKGoldberg added the enhancement New feature or request label Aug 26, 2023
@JoshuaKGoldberg
Copy link
Collaborator Author

@cpreston321 that PR doesn't resolve this issue though. It just runs s.start and s.stop around the tasks. This issue is for nesting tasks within the spinners.

@cpreston321 cpreston321 reopened this Aug 29, 2023
@cpreston321
Copy link
Collaborator

@JoshuaKGoldberg Got it, i reopened the issue.

So if task 1 completes it moves to task 2.. Let's say if task 2 fails does that kick out of the task process / cancel the spinner ?


Also if it easier you can create a draft pull request with some examples. I think for this functionality we can keep this at the @clack/prompt level. I think in the future we can think more of creating standalone helper primitives in a separate package.

@JoshuaKGoldberg
Copy link
Collaborator Author

if task 2 fails does that kick out of the task process / cancel the spinner ?

I would think so, yeah. At least by default. Maybe there could be an API option for whether to bail or continue?

create a draft pull request with some examples

Yes! #158 is roughly what I was thinking of. I haven't put too much thought into the API design, pending posting here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants