puvox-library 1.0.19 → 1.0.21
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 +26 -31
- package/package.json +1 -1
package/library_standard.js
CHANGED
@@ -588,41 +588,36 @@ const puvox_library =
|
|
588
588
|
|
589
589
|
argvsString(){ return process.argv[2]; },
|
590
590
|
argvsArray(){ return process.argv.slice(2); },
|
591
|
-
|
592
|
-
|
591
|
+
argvs(){ return this.argvsArray();},
|
592
|
+
|
593
|
+
argv(which, def = undefined){
|
593
594
|
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);
|
595
|
+
let KeyValues= {};
|
596
|
+
for (let i=0; i<argvs.length; i++){
|
597
|
+
let argumentString = argvs[i]; // each argument
|
598
|
+
let pair = {};
|
599
|
+
if ( argumentString.includes('=') ){
|
600
|
+
pair = this.parseQuery(argumentString);
|
601
|
+
} else {
|
602
|
+
pair[argumentString] = undefined;
|
603
|
+
}
|
604
|
+
let pairKey= Object.keys(pair)[0];
|
605
|
+
// if member already exists (i.e: cli key1=val1 key2=val2 key1=xyz..)
|
606
|
+
if (pairKey in KeyValues){
|
607
|
+
// if not array yet
|
608
|
+
if (!Array.isArray(KeyValues[pairKey]))
|
609
|
+
{
|
610
|
+
KeyValues[pairKey] = [ KeyValues[pairKey], pair[pairKey]];
|
611
|
+
}
|
612
|
+
// if already array-ed
|
613
|
+
else {
|
614
|
+
KeyValues[pairKey] = KeyValues[pairKey].concat([pair[pairKey]]);
|
622
615
|
}
|
616
|
+
} else {
|
617
|
+
KeyValues = Object.assign (KeyValues, pair);
|
623
618
|
}
|
624
|
-
return (which==undefined ? KeyValues : (which in KeyValues ? KeyValues[which] : undefined) );
|
625
619
|
}
|
620
|
+
return (which in KeyValues ? KeyValues[which] : def);
|
626
621
|
},
|
627
622
|
argvIsSet(which){
|
628
623
|
return this.inArray(which, this.argvsArray()) || this.argv(which)!=undefined;
|