Skip to content

定制提示类型

除了为命令选项自动推断交互提示类型外,也可以手动指定提示类型。

js
const { MixCommand } = require('mixcli');

/**
 * @param {import('mixcli').MixCli} cli
 */
 module.exports = (cli)=>{    
    
  const restartCommand = new MixCommand();
    restartCommand
        .name("restart")
        .prompt([
            {
                name: "force",
                type: "confirm",
                message: "是否强制重启?",
                default: false
            }
        ])
 }
const { MixCommand } = require('mixcli');

/**
 * @param {import('mixcli').MixCli} cli
 */
 module.exports = (cli)=>{    
    
  const restartCommand = new MixCommand();
    restartCommand
        .name("restart")
        .prompt([
            {
                name: "force",
                type: "confirm",
                message: "是否强制重启?",
                default: false
            }
        ])
 }
  • prompt方法添加自定义的prompt,每个选项都是一个对象PromptObject,对象的属性请参阅prompts