1

yargs モジュールで使用されるコマンド関数とそれに渡されるオブジェクトのプロパティを理解しようとしています。内部で使用されるハンドラ関数に関して。argv は、コマンド関数に渡されたオブジェクトのビルダー プロパティを表していますか?

yargs.command({ //accepts an object as a parameter
    command: 'add', //name of command
    describe: 'Add a new note', //description,
    builder: {
        title: {
            describe: 'Note title',
            demandOption: true, //Title must be provided if true
            type: 'string' // needs to be a strin
        },
        body: {
            describe: 'Note body',
            demandOption: true, //Title must be provided if true
            type: 'string' // needs to be a strin
        }
    },
    handler: function (argv) {
        console.log('Title: ' + argv.title)
        console.log('Body: ' + argv.body)
    }
});```

4

1 に答える 1