Permalink
Browse files

Fixed --version, added empty value checks for --format and --lang opt…

…ions
  • Loading branch information...
1 parent a3d00cf commit 9be2450ca93f51a1313e0b85f4ea4db25cdd8c73 @arikon arikon committed Sep 1, 2011
Showing with 7 additions and 1 deletion.
  1. +7 −1 lib/cli.js
View
@@ -35,8 +35,9 @@ exports.main = function () {
.title('Language: js, xml')
.short('l')
.long('lang')
- .req()
.val(function(value) {
+ // FIXME: don't use private API _usage()
+ !value && this.end().errorExit("Missing required option value\n" + this._usage());
(['js', 'xml'].indexOf(value) == -1) && this.end()
.errorExit('Wrong language "' + value + '" specified, must be one of "js" or "xml"');
return value;
@@ -49,6 +50,8 @@ exports.main = function () {
.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;
@@ -62,6 +65,9 @@ exports.main = function () {
.flag()
.end()
.act(function(opts) {
+ // FIXME: don't use private API _optsByKey
+ !opts.lang && (this.errorExit(this._optsByKey['--lang']._requiredText()));
+
(opts.input ?
// if input file
function(inputFn) {

0 comments on commit 9be2450

Please sign in to comment.