coa icon indicating copy to clipboard operation
coa copied to clipboard

API for empty option value checks

Open arikon opened this issue 13 years ago • 0 comments

        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()

arikon avatar Sep 01 '11 11:09 arikon