API for empty option value checks #2

Open
arikon opened this Issue Sep 1, 2011 · 0 comments

Projects

None yet

1 participant

@arikon
Collaborator
arikon commented Sep 1, 2011
        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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment