Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR overhauls the CLI and solves #69 and #76.
Commander replaced with Yargs
Replaced commander with yargs as commander offered no support for nested commands. Yargs is also much more actively maintained and improved.
Nested commands nested help
User help and guidance has been greatly improved. Running
lore
will now generate help automatically that looks like this. Note that all generators are grouped intogenerate
, and we can easily add more categories (like initializers, tutorial, whatever) over time.If you then run
lore generate
you will get a list of all generators:And if you run
lore generate component
you'll get help specific to that command that shows the options:Well-behaved CLI Arguments
CLI arguments are now respected like you would expect from a real CLI. This solves #69. The following commands are all valid:
Colors!
Color has been added to the output for improved readability. This was done through debug and debug-logger, though there's an issue (called out below).
Improved Extensibility
As a big step towards making the CLI extensible, all generators now define their own interface, that looks like this:
This is the interface for
lore-generate-model
. All generators also inherit fromGenerator
inlore-generate
using a template pattern. For example, this is the interface forlore-generate-model
:All generators have access to a
logger
that supportstrace, debug, log, info, warn, error
.Steps needed to complete extensibility
Two things need to be done to support an extendible CLI:
lore-cli
needs to inspect the.lorerc
file and look for other generators, then dynamically load them.category
field.Issue w/ Debug
The CLI uses debug as the underlying logger, but it has a hard-coded feature that means ALL logs have a timestamp attached to them. While not too obnoxious for simple statements, it severely impacts the readability of instructions like this:
There is a PR to make it optional but it hasn't been accepted for merge. I'll either fork
debug
and use that version (to disable timestamps) or find a different logging solution. Undecided.