feat(v2): allow plugin to extendCli (#1843)

* feat(v2): allow plugin to extendCli

* rename to externalCommand
This commit is contained in:
Endi 2019-10-16 13:16:26 +07:00 committed by GitHub
parent 46e8e03be0
commit b1f6951fbb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 137 additions and 52 deletions

View file

@ -130,6 +130,23 @@ configureWebpack(config, isServer, {getBabelLoader, getCacheLoader}) {
},
```
## extendCli(cli)
Register an extra command to enhance the CLI of docusaurus. `cli` is [commander](https://www.npmjs.com/package/commander) object.
Example:
```js
extendCli(cli) {
cli
.command('roll')
.description('Roll a random number between 1 and 1000')
.action(() => {
console.log(Math.floor(Math.random() * 1000 + 1));
});
},
```
<!--
For example, the in docusaurus-plugin-content-docs:
@ -210,6 +227,10 @@ module.exports = function(context, opts) {
// in the client bundle. These modules are imported globally before
// React even renders the initial UI.
},
extendCli(cli) {
// Register an extra command to enhance the CLI of docusaurus
},
};
};
```