coa
coa copied to clipboard
API for empty option value checks
cmd.opt()
.name('format')
.title('Output format: html, bemjson. Defaults to html')
.short('f')
.long('format')
.def('html')
.val(function(value) {
// FIXME: don't use private API _usage()
!value && this.end().errorExit("Missing required option value\n" + this._usage());
(['html', 'bemjson'].indexOf(value) == -1) && this.end()
.errorExit('Wrong output format "' + value + '" specified, must be one of "html" or "bemjson"');
return value;
})
.end()