Comparing version 0.0.4 to 0.0.5
/** | ||
* cmdline.js - cmdline is a process.argv parser | ||
* @version v0.0.4 | ||
* @version v0.0.5 | ||
* @link http://houfeng.net/cmdline | ||
@@ -9,2 +9,2 @@ * @license MIT | ||
*/ | ||
var utils=require("real-utils"),CommandLine=module.exports=function(o){var t=this;t.opts=o||{},t.parse(),t.initExtendMethods()};CommandLine.prototype.parse=function(){var o=this,t=utils.clone(process.argv);t=t.splice(2),o.options=[],o.args=[];var n=new RegExp("^-");t.forEach(function(t){n.test(t)?o.options.push(t.replace(":","=")):o.args.push(t)}),o.opts.commandEnabled&&(o.command=o.args[0]||"",o.args=o.args.splice(1))},CommandLine.prototype.initExtendMethods=function(){var o=this;o.options.has=function(t){for(var n=0;n<o.options.length;n++){var s=o.options[n];if(s==t||s.split("=")[0]==t)return!0}return!1},o.options.getValue=function(t){for(var n=0;n<o.options.length;n++){var s=o.options[n];if(s==t||s.split("=")[0]==t)return s.split("=")[1]}return null},o.options.setValue=function(t,n){if(o.options.has(t)){var s=o.options;o.options.splice(0,o.options.length);for(var i=0;i<s.length;i++){var e=s[i];e!=t&&e.split("=")[0]!=t&&o.options.push(e)}}o.options.push(t+"="+n)},o.options.getNodeOptions=function(){for(var t=[],n=new RegExp("^--"),s=0;s<o.options.length;s++){var i=o.options[s];n.test(i)&&t.push(i)}return t}}; | ||
var utils=require("real-utils"),CommandLine=module.exports=function(t){var o=this;o.opts=t||{},o.parse(),o.initExtendMethods()};CommandLine.prototype.parse=function(){var t=this,o=utils.clone(process.argv);o=o.splice(2),t.options=[],t.args=[];var n=new RegExp("^-");o.forEach(function(o){n.test(o)?t.options.push(o.replace(":","=")):t.args.push(o)}),t.opts.commandEnabled&&(t.command=t.args[0]||"",t.args=t.args.splice(1))},CommandLine.prototype.initExtendMethods=function(){var t=this;t.options.has=function(o){return t.options.some(function(t){return t==o||t.split("=")[0]==o?!0:void 0})},t.options.getValue=function(o){for(var n=0;n<t.options.length;n++){var s=t.options[n];if(s==o||s.split("=")[0]==o)return s.split("=")[1]}return null},t.options.setValue=function(o,n){if(t.options.has(o)){var s=utils.clone(t.options);t.options.splice(0,t.options.length);for(var i=0;i<s.length;i++){var e=s[i];e!=o&&e.split("=")[0]!=o&&t.options.push(e)}}t.options.push(o+"="+n)},t.options.getNodeOptions=function(){var o=new RegExp("^--");return t.options.filter(function(t){return o.test(t)})}}; |
{ | ||
"name": "cmdline", | ||
"rawName": "cmdline", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "cmdline is a process.argv parser", | ||
@@ -6,0 +6,0 @@ "main": "./lib/cmdline.js", |
cmdline is a process.argv parser, | ||
current version v0.0.4 | ||
current version v0.0.5 |
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
2354