puvox-library 1.0.20 → 1.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/library_standard.js +24 -31
- package/package.json +1 -1
package/library_standard.js
CHANGED
@@ -588,41 +588,34 @@ const puvox_library =
|
|
588
588
|
|
589
589
|
argvsString(){ return process.argv[2]; },
|
590
590
|
argvsArray(){ return process.argv.slice(2); },
|
591
|
-
|
592
|
-
var which = which || undefined;
|
591
|
+
argvs(){
|
593
592
|
let argvs= this.argvsArray();
|
594
|
-
|
595
|
-
{
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
KeyValues[pairKey] = [ KeyValues[pairKey], pair[pairKey]];
|
615
|
-
}
|
616
|
-
// if already array-ed
|
617
|
-
else {
|
618
|
-
KeyValues[pairKey] = KeyValues[pairKey].concat([pair[pairKey]]);
|
619
|
-
}
|
620
|
-
} else {
|
621
|
-
KeyValues = Object.assign (KeyValues, pair);
|
593
|
+
let KeyValues= {};
|
594
|
+
for (let i=0; i<argvs.length; i++){
|
595
|
+
let argumentString = argvs[i]; // each argument
|
596
|
+
let pair = {};
|
597
|
+
if ( argumentString.includes('=') ){
|
598
|
+
pair = this.parseQuery(argumentString);
|
599
|
+
} else {
|
600
|
+
pair[argumentString] = undefined;
|
601
|
+
}
|
602
|
+
let pairKey= Object.keys(pair)[0];
|
603
|
+
// if member already exists (i.e: cli key1=val1 key2=val2 key1=xyz..)
|
604
|
+
if (pairKey in KeyValues){
|
605
|
+
// if not array yet
|
606
|
+
if (!Array.isArray(KeyValues[pairKey]))
|
607
|
+
{
|
608
|
+
KeyValues[pairKey] = [ KeyValues[pairKey], pair[pairKey]];
|
609
|
+
}
|
610
|
+
// if already array-ed
|
611
|
+
else {
|
612
|
+
KeyValues[pairKey] = KeyValues[pairKey].concat([pair[pairKey]]);
|
622
613
|
}
|
614
|
+
} else {
|
615
|
+
KeyValues = Object.assign (KeyValues, pair);
|
623
616
|
}
|
624
|
-
return (which==undefined ? KeyValues : (which in KeyValues ? KeyValues[which] : undefined) );
|
625
617
|
}
|
618
|
+
return KeyValues;
|
626
619
|
},
|
627
620
|
argvIsSet(which){
|
628
621
|
return this.inArray(which, this.argvsArray()) || this.argv(which)!=undefined;
|