@vexify-org/yaggs 6.18.0 → 6.19.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.
Files changed (3) hide show
  1. package/index.js +21 -0
  2. package/lib/parser.js +27 -0
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -233,6 +233,27 @@ class Yaggs {
233
233
  return this.parser.sha512(str);
234
234
  }
235
235
 
236
+ env(key, value) {
237
+ if (value !== undefined) {
238
+ this.parser.env(key, value);
239
+ return this;
240
+ }
241
+ return this.parser.env(key);
242
+ }
243
+
244
+ getEnv(key) {
245
+ return this.parser.getEnv(key);
246
+ }
247
+
248
+ setEnv(key, value) {
249
+ this.parser.setEnv(key, value);
250
+ return this;
251
+ }
252
+
253
+ listEnv(filter = '') {
254
+ return this.parser.listEnv(filter);
255
+ }
256
+
236
257
  check(fn) {
237
258
  this.middleware(fn);
238
259
  return this;
package/lib/parser.js CHANGED
@@ -1219,6 +1219,33 @@ complete -c ${this.scriptName} `;
1219
1219
  return this.hash(str, 'sha512');
1220
1220
  }
1221
1221
 
1222
+ env(key, value) {
1223
+ if (value !== undefined) {
1224
+ process.env[key] = value;
1225
+ return this;
1226
+ }
1227
+ return process.env[key];
1228
+ }
1229
+
1230
+ getEnv(key) {
1231
+ return process.env[key];
1232
+ }
1233
+
1234
+ setEnv(key, value) {
1235
+ process.env[key] = value;
1236
+ return this;
1237
+ }
1238
+
1239
+ listEnv(filter = '') {
1240
+ const env = {};
1241
+ for (const [key, value] of Object.entries(process.env)) {
1242
+ if (filter === '' || key.toLowerCase().includes(filter.toLowerCase())) {
1243
+ env[key] = value;
1244
+ }
1245
+ }
1246
+ return env;
1247
+ }
1248
+
1222
1249
  getHelp() {
1223
1250
  let help = `\u001b[36m${this.scriptName}\u001b[0m`;
1224
1251
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vexify-org/yaggs",
3
- "version": "6.18.0",
3
+ "version": "6.19.0",
4
4
  "description": "A powerful CLI argument parser, better than yargs",
5
5
  "main": "index.js",
6
6
  "scripts": {