@vexify-org/yaggs 6.14.0 → 6.15.0

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/index.js CHANGED
@@ -185,6 +185,10 @@ class Yaggs {
185
185
  return this.parser.file(path, options);
186
186
  }
187
187
 
188
+ template(str, data = {}) {
189
+ return this.parser.template(str, data);
190
+ }
191
+
188
192
  check(fn) {
189
193
  this.middleware(fn);
190
194
  return this;
package/lib/parser.js CHANGED
@@ -1129,6 +1129,24 @@ complete -c ${this.scriptName} `;
1129
1129
  };
1130
1130
  }
1131
1131
 
1132
+ template(str, data = {}) {
1133
+ return str.replace(/{{([^}]+)}}/g, (match, key) => {
1134
+ const keys = key.trim().split('.');
1135
+ let value = data;
1136
+
1137
+ for (const k of keys) {
1138
+ if (value && typeof value === 'object') {
1139
+ value = value[k];
1140
+ } else {
1141
+ value = undefined;
1142
+ break;
1143
+ }
1144
+ }
1145
+
1146
+ return value !== undefined ? value : match;
1147
+ });
1148
+ }
1149
+
1132
1150
  getHelp() {
1133
1151
  let help = `\u001b[36m${this.scriptName}\u001b[0m`;
1134
1152
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vexify-org/yaggs",
3
- "version": "6.14.0",
3
+ "version": "6.15.0",
4
4
  "description": "A powerful CLI argument parser, better than yargs",
5
5
  "main": "index.js",
6
6
  "scripts": {