PageSourceSearch

https://oclif.io/assets/js/e360e27f.9ff0c4ba.js

js oclif.io collected 2026-10-02 05:28:12 UTC 6,006 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[191],{5785(n,i,e){e.r(i),e.d(i,{assets:()=>u,contentTitle:()=>t,default:()=>d,frontMatter:()=>s,metadata:()=>c,toc:()=>r});var l=e(4848),o=e(8453);const s={title:"Plugins"},t=void 0,c={id:"plugins",title:"Plugins",description:"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.",source:"@site/../docs/plugins.md",sourceDirName:".",slug:"/plugins",permalink:"/docs/plugins",draft:!1,unlisted:!1,editUrl:"https://github.com/oclif/oclif.github.io/tree/docs/docs/../docs/plugins.md",tags:[],version:"current",lastUpdatedBy:"svc-cli-bot",lastUpdatedAt:1786417797e3,frontMatter:{title:"Plugins"},sidebar:"docs",previous:{title:"Hooks",permalink:"/docs/hooks"},next:{title:"Help Classes",permalink:"/docs/help_classes"}},u={},r=[{value:"Useful Plugins",id:"useful-plugins",level:2},{value:"Building your own plugin",id:"building-your-own-plugin",level:2}];function a(n){const i={a:"a",code:"code",h2:"h2",li:"li",p:"p",pre:"pre",ul:"ul",...(0,o.R)(),...n.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(i.p,{children:"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."}),"\n",(0,l.jsxs)(i.p,{children:["Plugins can have commands or hooks just like a CLI. To add a plugin such as the ",(0,l.jsx)(i.a,{href:"https://github.com/oclif/plugin-not-found",children:"not-found plugin"})," plugin, first add it to your CLI with ",(0,l.jsx)(i.code,{children:"yarn add @oclif/plugin-not-found"}),", then add the following to your ",(0,l.jsx)(i.code,{children:"package.json"}),":"]}),"\n",(0,l.jsx)(i.pre,{children:(0,l.jsx)(i.code,{className:"language-js",children:'{\n  "name": "mycli",\n  "version": "0.0.0",\n  // ...\n  "dependencies": {\n    "@oclif/core": "^3",\n    "@oclif/plugin-help": "^6",\n    "@oclif/plugin-not-found": "^3",\n  }\n  "oclif": {\n    "plugins": [\n      "@oclif/plugin-help",\n      "@oclif/plugin-not-found"\n    ]\n  }\n}\n'})}),"\n",(0,l.jsxs)(i.p,{children:["Plugins can also be specified using ",(0,l.jsx)(i.a,{href:"https://www.npmjs.com/package/minimatch?activeTab=readme",children:"minimatch"})," patterns:"]}),"\n",(0,l.jsx)(i.pre,{children:(0,l.jsx)(i.code,{className:"language-js",children:'{\n  "name": "mycli",\n  "version": "0.0.0",\n  // ...\n  "dependencies": {\n    "@oclif/core": "^3",\n    "@oclif/plugin-help": "^6",\n    "@oclif/plugin-not-found": "^3",\n  }\n  "oclif": {\n    "plugins": [\n      "@oclif/plugin-*",\n    ]\n  }\n}\n'})}),"\n",(0,l.jsxs)(i.p,{children:["If you want users to be able to install their own plugins into your CLI, use the ",(0,l.jsx)(i.a,{href:"https://github.com/oclif/plugin-plugins",children:"plugins plugin"}),"."]}),"\n",(0,l.jsx)(i.h2,{id:"useful-plugins",children:"Useful Plugins"}),"\n",(0,l.jsxs)(i.ul,{children:["\n",(0,l.jsxs)(i.li,{children:[(0,l.jsx)(i.a,{href:"https://github.com/oclif/plugin-not-found",children:"@oclif/plugin-not-found"}),' - Display a friendly "did you mean" message if a command is not found.']}),"\n",(0,l.jsxs)(i.li,{children:[(0,l.jsx)(i.a,{href:"https://github.com/oclif/plugin-plugins",children:"@oclif/plugin-plugins"})," - Allow users to add plugins to extend your CLI."]}),"\n",(0,l.jsxs)(i.li,{children:[(0,l.jsx)(i.a,{href:"https://github.com/oclif/plugin-update",children:"@oclif/plugin-update"})," - Add autoupdate support to the CLI."]}),"\n",(0,l.jsxs)(i.li,{children:[(0,l.jsx)(i.a,{href:"https://github.com/oclif/plugin-help",children:"@oclif/plugin-help"})," - Help plugin for oclif."]}),"\n",(0,l.jsxs)(i.li,{children:[(0,l.jsx)(i.a,{href:"https://github.com/oclif/plugin-warn-if-update-available",children:"@oclif/plugin-warn-if-update-available"})," - Show a warning message if user is running an out of date CLI."]}),"\n",(0,l.jsxs)(i.li,{children:[(0,l.jsx)(i.a,{href:"https://github.com/oclif/plugin-which",children:"@oclif/plugin-which"})," - Show which plugin a command comes from."]}),"\n",(0,l.jsxs)(i.li,{children:[(0,l.jsx)(i.a,{href:"https://github.com/oclif/plugin-commands",children:"@oclif/plugin-commands"}
1)," - Add a ",(0,l.jsx)(i.code,{children:"commands"})," command to list all the commands."]}),"\n",(0,l.jsxs)(i.li,{children:[(0,l.jsx)(i.a,{href:"https://github.com/oclif/plugin-autocomplete",children:"@oclif/plugin-autocomplete"})," - Add bash/zsh autocomplete."]}),"\n",(0,l.jsxs)(i.li,{children:[(0,l.jsx)(i.a,{href:"https://github.com/oclif/plugin-search",children:"@oclif/plugin-search"})," - Add ",(0,l.jsx)(i.code,{children:"search"})," command to your CLI."]}),"\n",(0,l.jsxs)(i.li,{children:[(0,l.jsx)(i.a,{href:"https://github.com/oclif/plugin-version",children:"@oclif/plugin-version"})," - Add ",(0,l.jsx)(i.code,{children:"version"})," command to your CLI."]}),"\n"]}),"\n",(0,l.jsx)(i.h2,{id:"building-your-own-plugin",children:"Building your own plugin"}),"\n",(0,l.jsx)(i.p,{children:"Writing code for plugins is essentially the same as writing within a CLI. They can export 3 different types: commands, hooks, and other plugins."}),"\n",(0,l.jsxs)(i.p,{children:["Run ",(0,l.jsx)(i.code,{children:"npx oclif generate mynewplugin"})," to create a plugin in a new directory. This will come with a sample commands called ",(0,l.jsx)(i.code,{children:"hello"})," and ",(0,l.jsx)(i.code,{children:"hello world"}),"."]})]})}function d(n={}){const{wrapper:i}={...(0,o.R)(),...n.components};return i?(0,l.jsx)(i,{...n,children:(0,l.jsx)(a,{...n})}):a(n)}},8453(n,i,e){e.d(i,{R:()=>t,x:()=>c});var l=e(6540);const o={},s=l.createContext(o);function t(n){const i=l.useContext(s);return l.useMemo((function(){return"function"==typeof n?n(i):{...i,...n}}),[i,n])}function c(n){let i;return i=n.disableParentContext?"function"==typeof n.components?n.components(o):n.components||o:t(n.components),l.createElement(s.Provider,{value:i},n.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.