缺少必需的参数"电子邮件"



缺少必需的参数'email'

你好

我正在尝试使用nodejs制作一个命令行接口,因为我一直在尝试更好地学习它
到目前为止,一切都在按计划进行
正如你应该知道的,因为我很清楚地说,我正在学习节点,所以我并没有完全坦白所有的错误
我的界面是用于管理客户的,一切都很好,但当我运行时就会发生这种情况

node commands.js add john doe 555-555-5555 john@gmail.com

通过命令行。这是我运行它时遇到的错误。

error: missing required argument 'email'

这是我的代码,如果有人想看一看的话。

const program = require('commander');
const {
addCustomer,
findCustomer
} = require('./index');
program
.version('1.0.0')
.description('Client Management System')
program
.command('add <firstname> <lastname> <dob> <phone> <email>')
.alias('a')
.description('Add a customer')
.action((firstname, lastname, dob, phone, email) => {
addCustomer({firstname, lastname, dob, phone, email});
}),
program
.command('find <name>')
.alias('f')
.description('Find a customer')
.action(name => findCustomer(name));
program.parse(process.argv);

您错过DOB数据了吗?

node commands.js add john doe 555-555-5555 john@gmail.com

应该是类似的东西

node commands.js add john doe 2011-1-2 555-555-5555 john@gmail.com

最新更新