oclif: The Open CLI Framework
  • Getting Started
  • API Reference
  • Blog
  • GitHub

›API Reference

Getting Started

  • Introduction
  • Features
  • FAQs
  • Generator Commands

API Reference

  • Commands
  • Command Arguments
  • Command Flags
  • Configuration
  • Topics
  • Topic Separators
  • Hooks
  • Plugins
  • Help Classes
  • Error Handling
  • JSON

How to

  • Release
  • Testing
  • Running Commands Programmatically
  • Aliases
  • Custom Base Class
  • Prompting
  • Spinner
  • Table
  • Notifications
  • Debugging
  • Flexible Taxonomy
  • Global Flags

Also See

  • Examples
  • External Links
  • Related Repositories
  • How We Work
  • Feedback
Edit

Plugins

Plugins are a great way to offer experimental functionality, allow users to extend your CLI, break up a CLI into modular components, or share functionality between CLIs.

Plugins can have commands or hooks just like a CLI. To add a plugin such as the not-found plugin plugin, first add it to your CLI with yarn add @oclif/plugin-not-found, then add the following to your package.json:

{
  "name": "mycli",
  "version": "0.0.0",
  // ...
  "oclif": {
    "plugins": [
      "@oclif/plugin-help",
      "@oclif/plugin-not-found"
    ]
  }
}

If you want users to be able to install their own plugins into your CLI, use the plugins plugin.

Useful Plugins

  • @oclif/plugin-not-found - Display a friendly "did you mean" message if a command is not found.
  • @oclif/plugin-plugins - Allow users to add plugins to extend your CLI.
  • @oclif/plugin-update - Add autoupdate support to the CLI.
  • @oclif/plugin-help - Help plugin for oclif.
  • @oclif/plugin-warn-if-update-available - Show a warning message if user is running an out of date CLI.
  • @oclif/plugin-which - Show which plugin a command comes from.
  • @oclif/plugin-commands - Add a commands command to list all the commands.
  • @oclif/plugin-autocomplete - Add bash/zsh autocomplete.

Community Plugins

  • conf-cli - Adds a conf command to share state/configuration between commands. Uses sindresorhus/conf.
  • Add yours here!

Building your own plugin

Writing code for plugins is essentially the same as writing within a CLI. They can export 3 different types: commands, hooks, and other plugins.

Run npx oclif plugin mynewplugin to create a plugin in a new directory. This will come with a sample command called hello.

Last updated on 10/17/2018
← HooksHelp Classes →
Made with 💜 by Salesforce — MIT License