Permalink
Browse files

a little tiddying

  • Loading branch information...
1 parent d4a9191 commit a95d2752d7323ea4135d1da6f2f1be958fb9a909 Dmytri Kleiner committed Dec 18, 2010
Showing with 9 additions and 18 deletions.
  1. +1 −1 example.js
  2. +8 −17 operetta.js
View
@@ -7,7 +7,7 @@ var args = ['test', 'hello',
'-t', '-tclosetest', '-xtcloser', '-xt', 'another', 'test', '--test', 'long', 'test',
'-t', 'short', 'test', '--test=equals_test','--flag','/path/to/some/file'];
-console.log("[", args.join(" "), "]");
+console.log("[", args.join(" "), "]\n");
var operetta = new Operetta(args);
View
@@ -79,40 +79,31 @@ Operetta.prototype.start = function(listener) {
var options = m[1][1] + m[2];
for (i in options) {
var option = operetta.opts["-" + options[i]];
- if (option) {
- parse(option);
- } else {
+ if (option) parse(option);
+ else {
parse("-" + options[i], options.slice(parseInt(i) + 1));
break;
}
}
} else parse(m[1] || m[3], m[4]);
- } else if (parameter) {
- sing(parameter, arg);
- } else sing("positional", arg);
+ } else if (parameter) sing(parameter, arg);
+ else sing("positional", arg);
}
if (listener) listener(operetta.values);
};
Operetta.prototype.bind = function(args, description, listener, takes_arguments) {
if (args) {
var operetta = this;
- if (!(args != null && typeof args === "object" && "join" in args)) {
- args = [args];
- }
+ if (!(args != null && typeof args === "object" && "join" in args)) args = [args];
var key = args[0];
sargs = args.join(",");
operetta.help += "\n" + args + Array(16 - sargs.length).join(" ") + description;
args.forEach(function(option){
- if (takes_arguments) {
- operetta.params[option] = key;
- } else {
- operetta.opts[option] = key;
- }
+ if (takes_arguments) operetta.params[option] = key;
+ else operetta.opts[option] = key;
});
- if (listener) {
- operetta.on(key, listener);
- }
+ if (listener) operetta.on(key, listener);
}
};

0 comments on commit a95d275

Please sign in to comment.