Skip to content

Imperative Configuration

Adam Wolfe edited this page Aug 1, 2024 · 1 revision

Overview

A key component of an Imperative based CLI is it's Imperative configuration document. Detailed documentation can be found in the typedoc of the IImperativeConfig interface. In summary, the configuration document is the mechanism by which you will configure the imperative framework for your CLI. On the document you provide the CLI name, command definition and option documents, profile definitions, plugin capabilities and more.

Note: The general Imperative philosophy is to assume you would like all features enabled by default. This philosophy cuts down on the amount of required configuration and provides the most "out of the box" value without needing to understand all configuration or features.

Configuration

You must supply the configuration document in your package.json. There are two forms of the package.json configuration.

Supplying Configuration in package.json

You can supply the entire static configuration document in your package.json using the imperative property:

"imperative": {
    "productDisplayName": "Example Command Line Interface",
    "definitions": [{
        "name": "hello",
        "description": "A sample command",
        "type": "command",
        "handler": "/path/to/handler"
    }],
    "rootCommandDescription": "Welcome to the Example CLI",
    "envVariablePrefix": "SAMPLE_CLI"
}

Supplying a Configuration Module

You can supply the configuration document in a module and "point" to it using the imperative property in your package.json:

"imperative": {
    "configurationModule": "lib/imperative.js"
}