@ztimson/utils 0.23.3 → 0.23.5

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.cjs CHANGED
@@ -28,7 +28,10 @@ var __publicField = (obj, key, value2) => __defNormalProp(obj, typeof key !== "s
28
28
  var _a;
29
29
  return !(arg instanceof ArgParser) && !((_a = arg.flags) == null ? void 0 : _a.length);
30
30
  });
31
- this.flags = [...argList.filter((arg) => !(arg instanceof ArgParser) && arg.flags && arg.flags.length), ...this.flags];
31
+ this.flags = [
32
+ ...argList.filter((arg) => !(arg instanceof ArgParser) && arg.flags && arg.flags.length),
33
+ { name: "help", desc: "Display command's help message", flags: ["-h", "--help"], default: false }
34
+ ];
32
35
  this.defaults = argList.reduce((acc, arg) => ({ ...acc, [arg.name]: arg["extras"] ? [] : arg.default ?? null }), {});
33
36
  this.examples = [
34
37
  ...examples,
@@ -105,14 +108,14 @@ var __publicField = (obj, key, value2) => __defNormalProp(obj, typeof key !== "s
105
108
  let msg = `
106
109
 
107
110
  ${opts.message || this.desc}`;
108
- msg += "\n\nUsage: " + this.examples.map((ex) => `run ${this.name} ${ex}`).join("\n ");
109
- if (this.args.length) msg += "\n\n " + this.args.map((arg) => `${arg.name.toUpperCase()}${spacer(arg.name)}${arg.desc}`).join("\n ");
110
- msg += "\n\nOptions:\n " + this.flags.map((flag) => {
111
+ msg += "\n\nUsage: " + this.examples.map((ex) => `${this.name} ${ex}`).join("\n ");
112
+ if (this.args.length) msg += "\n\n " + this.args.map((arg) => `${arg.name.toUpperCase()}${spacer(arg.name)}${arg.desc}`).join("\n ");
113
+ msg += "\n\nOptions:\n " + this.flags.map((flag) => {
111
114
  var _a;
112
115
  const flags = ((_a = flag.flags) == null ? void 0 : _a.join(", ")) || "";
113
116
  return `${flags}${spacer(flags)}${flag.desc}`;
114
- }).join("\n ");
115
- if (this.commands.length) msg += "\n\nCommands:\n " + this.commands.map((command) => `${command.name}${spacer(command.name)}${command.desc}`).join("\n ");
117
+ }).join("\n ");
118
+ if (this.commands.length) msg += "\n\nCommands:\n " + this.commands.map((command) => `${command.name}${spacer(command.name)}${command.desc}`).join("\n ");
116
119
  return `${msg}
117
120
 
118
121
  `;