salsita / spicy-hooks

7 stars 0 forks source link

Export command-line related helpers from `bin` #16

Open goce-cz opened 3 years ago

goce-cz commented 3 years ago

Currently the bin package doesn't export anything and publishes only the executable binaries.

The package however contains some interesting code related to parsing and handling command line arguments. We should export these and make them usable for building custom commands with easy and full TS support.

Namely I'm suggesting to export a helper that would create a command from given definitions, make it validate the arguments and automatically generate usage guide (--help).

Fezzzi commented 3 years ago

I am surprised something like this doesn't already exist but I wasn't able to find anything according to the description. I mean, why not export it when its already there, on the other hand, I am not entirely sure that this functionality has bigger usability as exported module then as another CLI command. Furthermore, I providing it as a CLI command would preserve mentioned structure of the bin package which I prefer (I am always a bit wierded out when I import some modular functionality from anything containing bin).

goce-cz commented 3 years ago

I am surprised something like this doesn't already exist

The code in the bin package just uses command-line-args and command-line-usage packages. We simply

So the functionality does exist, but still requires some manual work to get it to the shape we have. The stuff we would export is an opiniated all-in-one utility for handling standard commands.

has bigger usability as exported module then as another CLI command

How would you use CLI command to setup a CLI command? 🤔 I'm not suggesting to export the prepare-release, set-version or check-version functionality (even though it crossed my mind already). It's merely the code that orchestrates those command when you call spicy <command>.