@ztimson/utils 0.23.3 → 0.23.4

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/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value2) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value2 }) : obj[key] = value2;
3
3
  var __publicField = (obj, key, value2) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value2);
4
- class ArgParser {
4
+ const _ArgParser = class _ArgParser {
5
5
  /**
6
6
  * Create a unix-like argument parser to extract flags from the argument list. Can also create help messages.
7
7
  *
@@ -19,12 +19,12 @@ class ArgParser {
19
19
  this.desc = desc;
20
20
  this.argList = argList;
21
21
  this.examples = examples;
22
- this.commands = argList.filter((arg) => arg instanceof ArgParser);
22
+ this.commands = argList.filter((arg) => arg instanceof _ArgParser);
23
23
  this.args = argList.filter((arg) => {
24
24
  var _a;
25
- return !(arg instanceof ArgParser) && !((_a = arg.flags) == null ? void 0 : _a.length);
25
+ return !(arg instanceof _ArgParser) && !((_a = arg.flags) == null ? void 0 : _a.length);
26
26
  });
27
- this.flags = [...argList.filter((arg) => !(arg instanceof ArgParser) && arg.flags && arg.flags.length), ...this.flags];
27
+ this.flags = [...argList.filter((arg) => !(arg instanceof _ArgParser) && arg.flags && arg.flags.length), ...this.flags];
28
28
  this.defaults = argList.reduce((acc, arg) => ({ ...acc, [arg.name]: arg["extras"] ? [] : arg.default ?? null }), {});
29
29
  this.examples = [
30
30
  ...examples,
@@ -113,7 +113,9 @@ ${opts.message || this.desc}`;
113
113
 
114
114
  `;
115
115
  }
116
- }
116
+ };
117
+ __publicField(_ArgParser, "helpArg", { name: "help", desc: "Display command's help message", flags: ["-h", "--help"], default: false });
118
+ let ArgParser = _ArgParser;
117
119
  function clean(obj, undefinedOnly = false) {
118
120
  if (obj == null) throw new Error("Cannot clean a NULL value");
119
121
  if (Array.isArray(obj)) {