piuccio/cowsay

Is there a way to run cowthink directly via npx

dgwyer opened this issue · 3 comments

With npx you don't have to have the module installed directly on your computer. So you can do something like:

npx cowsay Hello!

But, this doesn't work:

npx cowthink Hello!

Is this because npx runs the module name cowsay and just runs the first command it finds in the "bin" field in package.json? Is there a way to run cowthink directly from npx as it is or with some code changes to the module?

This is relevant to me as I'm using your module to teach myself how to create node cli modules and would be interested in running multiple cli commands from a module invoked directly via npm remote calls.

I'm not quite sure how npx works, but if you find some documentation please post it here.

One option is to have a --think option, for now say and think is handled separately from other options but it wouldn't hurt to change that.

Feel free to open a PR

In java cowsay I faced a similar issue and have three main entry points:

  • Cowsay.say
  • Cowsay.think
  • Cowsay.main - this is the main entry point, it simply delegates to Cowsay.say unless it finds the flag --cowthink. The other methods do not recognise this arg.

I think a similar approach could work here.

I just merged a PR that allows to run npx cowsay --think hello. It'll be published eventually with cowsay 2