Skip to content

Enabling Plugins

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

This section explains how you enable the Plugin Management Facility (PMF) in a CLI application and how the PMF works in general. When you enable the PMF, you let your CLI accept incoming plug-ins developed by you or a 3rd party.

Using the Plugin Management Facility (PMF)

The PMF lets you manage plug-ins in an Imperative CLI Framework application.

When you initialize a CLI application, you set a parameter to enable or disable the PMF. The parameter that you set adds a plugins command group to your application that lets users install and manage plug-ins.

Enabling the Plugin Management Facility

The PMF is enabled by default in the allowPlugins parameter in ImperativeConfig.ts.

You can disable the PMF when you do not want to allow plug-ins in your CLI. When you set allowPlugins to false, the PMF is not initialized.

The following example illustrates how to disable plug-ins in ImperativeConfig.ts:

import {ICommandDefinition} from "../../../cmd";
import {IImperativeProfileConfig} from "./IImperativeProfileConfig";
import {IImperativeLogsConfig} from "./IImperativeLogsConfig";

/**
 * All of the configuration required to set up your Imperative CLI app
 */
export interface IImperativeConfig {
    /**
     * Boolean flag control wheather plugins are enable or disable.
     * This option is assumed to be true by default.
     */
    allowPlugins?: boolean;

Managing and loading installed plug-ins

Imperative CLI Framework uses the Plugins.json file to manage and load installed plug-ins. All plug-ins have a package.json file that contains the code structure of the plug-in.

You use the commands in the plugins command group to register the package that is defined in package.json in plugins.json.

Clone this wiki locally