Yeoman 获取选项

Yeoman Get Options

我写了这段代码:

this.option('username', {
    alias: 'u',
    name: 'Username',
    desc: 'A username used for Marketplace authentication',
    type: String,
    required: true
});

console.log(this.options.username);

我在终端输入以下内容:

yo test -username MrZerg

我回来了:

true

但我预计:"MrZerg"!

yo 正在使用 meow 解析命令行输入。我认为您需要双 -- 来输入选项。试试 yo test --username MrZerg