CLI Tutorial

A tutorial for learning to create your own commands

Overview

Creating your own commands for the Lore CLI is a great way to expand or modify the functionality provided by the framework. In the future, this section will include a tutorial that will teach you how to do that. But in the interim, the notes below may help you get started.

If you are interested in creating your own commands, please consider creating an issue describing what you're trying to do, and it may even be used as foundation for the tutorial.

This section is currently considered "lower priority" in favor of adding documentation elsewhere, but docs are prioritized based on perceived value, so speaking up is a good way to improve the prioritization of this tutorial.

Creating New Commands

The CLI has a command called lore generate generator <generator name> that will create a folder pre-configured as a working plugin for the Lore CLI. You can use this as a starting point for creating your own commands.

Debugging Module Loading

If you need to debug the module loading sequence for commands, you can add a debugLoading key in the options object of the .lorerc file.

{
  "generators": {
    "language": "es5"
  },
  "options": {
    "debugLoading": true
  }
}

When debugLoading is true, it will print out the directory of the modules that are being loaded, which can be helpful to confirm the CLI has loaded your custom command:

Loading absolute module: /Users/jchansen/lore/packages/lore-cli/node_modules/lore-extract-action
Loading absolute module: /Users/jchansen/lore/packages/lore-cli/node_modules/lore-extract-reducer
Loading directory module: ../../packages/lore-extract-action
Loading project module: lore-generate-collection
Loading project module: lore-generate-component