@@ -187,9 +187,8 @@ Then the final route of i18n UI is `/i18n/`.
## Others
With the goal of decoupling, we were able to separate VuePress into the following libraries by introducing monorepo:
With the goal of decoupling, we were able to separate VuePress into the following two libraries by introducing monorepo:
-[@vuepress/cli](https://github.com/vuejs/vuepress/tree/master/packages/@vuepress/cli): Management of command line;
-[@vuepress/core](https://github.com/vuejs/vuepress/tree/master/packages/@vuepress/core):Including the core implementation of `dev`, `build` and `Plugin API`;
-[@vuepress/theme-default](https://github.com/vuejs/vuepress/tree/master/packages/@vuepress/theme-default):The default theme you see now.
@@ -434,3 +434,29 @@ Then, VuePress will automatically inject these components behind the layout comp
</div>
</div>
```
## registerCommand
- Type: `function`
- Default: `undefined`
Register a extra command to enhance the CLI of vuepress. The function will be called with a [CAC](https://github.com/cacjs/cac)'s instance as the first argument.
```js
module.exports={
registerCommand(cli){
cli
.command('info [targetDir]','')
.option('--debug','display info in debug mode')
.action((dir='.')=>{
console.log('Display info of your website')
})
}
}
```
Now you can use `vuepress info [targetDir]` a in your project!
::: tip
Note that a custom command registered by a plugin requires VuePress to locate your site configuration like `vuepress dev` and `vuepress build`, so when developing a command, be sure to lead the user to pass `targetDir` as an CLI argument.
logger.tip(`Did you miss to specify the target docs dir? e.g. ${chalk.cyan(`vuepress ${commandName} [targetDir]`)}.`)
logger.tip(`A custom command registered by a plugin requires VuePress to locate your site configuration like ${chalk.cyan('vuepress dev')} or ${chalk.cyan('vuepress build')}.`)