What is @oclif/plugin-plugins?
@oclif/plugin-plugins is a plugin for the Oclif CLI framework that provides commands for managing other plugins. It allows you to install, uninstall, and list plugins for your Oclif CLI application.
What are @oclif/plugin-plugins's main functionalities?
Install a plugin
This feature allows you to install a new plugin into your Oclif CLI application. The code sample demonstrates how to use the 'plugins:install' command to add a plugin named 'my-plugin'.
await this.config.runCommand('plugins:install', ['my-plugin'])
Uninstall a plugin
This feature allows you to uninstall an existing plugin from your Oclif CLI application. The code sample shows how to use the 'plugins:uninstall' command to remove a plugin named 'my-plugin'.
await this.config.runCommand('plugins:uninstall', ['my-plugin'])
List installed plugins
This feature allows you to list all the plugins currently installed in your Oclif CLI application. The code sample demonstrates how to use the 'plugins' command to display the list of installed plugins.
await this.config.runCommand('plugins', [])
Other packages similar to @oclif/plugin-plugins
yeoman-environment
Yeoman Environment handles the lifecycle and bootstrapping of generators in the Yeoman ecosystem. It provides functionalities to register, load, and run generators, which are similar to plugins in Oclif. However, it is more focused on scaffolding projects rather than managing CLI plugins.
commander
Commander is a popular Node.js library for building command-line interfaces. While it does not have built-in support for managing plugins, it provides a flexible API for defining commands and options, which can be extended to support plugin-like functionality.
inquirer
Inquirer is a library for creating interactive command-line prompts. It can be used in conjunction with other CLI frameworks to enhance user interaction. While it does not manage plugins directly, it can be integrated into a CLI application to provide a better user experience.
@oclif/plugin-plugins
plugins plugin for oclif
What is this?
This plugin is used to allow users to install plugins into your oclif CLI at runtime. For example, in the Heroku CLI this is used to allow people to install plugins such as the Heroku Kafka plugin:
$ heroku plugins:install heroku-kafka
$ heroku kafka
This is useful to allow users to create their own plugins to work in your CLI or to allow you to build functionality that users can optionally install.
One particular way this is useful is for building functionality you aren't ready to include in a public repository. Build your plugin separately as a plugin, then include it as a core plugin later into your CLI.
Usage
First add the plugin to your project with yarn add @oclif/plugin-plugins
, then add it to the package.json
of the oclif CLI:
{
"name": "mycli",
"version": "0.0.0",
"oclif": {
"plugins": ["@oclif/plugin-help", "@oclif/plugin-plugins"]
}
}
Now the user can run any of the commands below to manage plugins at runtime.
Friendly names
To make it simpler for users to install plugins, we have "friendly name" functionality. With this, you can run mycli plugins:install myplugin
and it will first check if @mynpmorg/plugin-myplugin
exists on npm before trying to install myplugin
. This is useful if you want to use a generic name that's already taken in npm.
To set this up, simply set the oclif.scope
to the name of your npm org. In the example above, this would be mynpmorg
.
Commands
mycli plugins
list installed plugins
USAGE
$ mycli plugins
OPTIONS
--core show core plugins
EXAMPLE
$ mycli plugins
See code: src/commands/plugins/index.ts
mycli plugins:install PLUGIN...
installs a plugin into the CLI
USAGE
$ mycli plugins:install PLUGIN...
ARGUMENTS
PLUGIN plugin to install
OPTIONS
-h, --help show CLI help
-v, --verbose
DESCRIPTION
Can be installed from npm or a git url.
ALIASES
$ mycli plugins:add
EXAMPLES
$ mycli plugins:install myplugin
$ mycli plugins:install https://github.com/someuser/someplugin
$ mycli plugins:install someuser/someplugin
See code: src/commands/plugins/install.ts
mycli plugins:link PLUGIN
links a plugin into the CLI for development
USAGE
$ mycli plugins:link PLUGIN
ARGUMENTS
PATH [default: .] path to plugin
OPTIONS
-h, --help show CLI help
-v, --verbose
EXAMPLE
$ mycli plugins:link myplugin
See code: src/commands/plugins/link.ts
mycli plugins:uninstall PLUGIN...
removes a plugin from the CLI
USAGE
$ mycli plugins:uninstall PLUGIN...
ARGUMENTS
PLUGIN plugin to uninstall
OPTIONS
-h, --help show CLI help
-v, --verbose
ALIASES
$ mycli plugins:unlink
$ mycli plugins:remove
See code: src/commands/plugins/uninstall.ts
mycli plugins:update
update installed plugins
USAGE
$ mycli plugins:update
OPTIONS
-h, --help show CLI help
-v, --verbose
See code: src/commands/plugins/update.ts