infinitered/gluegun

Spin prevents the termination of the CLI

kaihaase opened this issue · 8 comments

Since version 4.0.0, the CLI is no longer terminated when a toolbox.print.spin is used. Even if the spinner was terminated via stop(), succeed() or fail().

Example:

const spinner = toolbox.print.spin('Start');
await toolbox.system.run('sleep 2');
spinner.succeed('End');
return;

Hey @kaihaase! I'm not seeing this issue. Seems to be working for me? What version of Node?

issue-609

Hey @jamonholmgren. Thank you for your quick analysis. I'm sorry, you're absolutely right. The error seems to occur only in a particular constellation. I haven't been able to figure out exactly what it is yet. However, I can reproduce it in an example repository: https://github.com/kaihaase/gluegun-spinner-bug.

Run example CLI and choose "test" in CLI menu:

$ git clone https://github.com/kaihaase/gluegun-spinner-bug.git
$ cd gluegun-spinner-bug
$ npm i
$ ./bin/spinner

If you execute 'test' directly via ./bin/spinner test the error does not occur.

However, since this is an exceptional case and the problem is easily solved by a process.exit() (see https://github.com/kaihaase/gluegun-spinner-bug/blob/33d46c7a9b9dad841a7b7f73b142359abae6bdd6/src/extensions/helper.extension.ts#L106), the issue can be closed.

Got it, thanks @kaihaase, and thanks for your detailed report. If you find an underlying issue with Gluegun I'm super happy to review a PR or provide guidance!.

Also, interesting way to use Gluegun, there!

@jamonholmgren We love gluegun and have started with our own CLI, which makes our daily work much easier. There will probably be a few more CLIs to follow, so we built a CLI starter right away. We found a "menu" helpful, so we outsourced it as a plugin. There it is called commandSelector. If you also find it useful, we could extend it further and integrate it directly into gluegun. Then only an autocompletion for the shell is missing. Maybe we could use something like tabtab or omelette. But what I wanted to say: many thanks for gluegun!

That's awesome!! We need to get this stuff in our README and other relevant documentation.

Can you add a GIF to the README of the menu plugin that shows how it works?

@jamonholmgren The menu used to be part of a help package. So that you can use it independently, I have created a new package: Gluegun Menu. I extended the README and added a GIF that shows the menu in action. It would be great if you could try the menu and suggest some improvements. I would be happy if you mentioned the Gluegun Menu in your README and other relevant documentation.