@bemoje/cli 1.0.2 → 1.0.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.
@@ -1,35 +1,31 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
1
  import { parseArgs } from "node:util";
6
2
  import { CommandHelpAdapter } from "./CommandHelpAdapter";
7
- const _Command = class _Command {
3
+ class Command {
4
+ /** Command name used for invocation */
5
+ name;
6
+ /** Optional version string */
7
+ version;
8
+ /** Alternative names for this command */
9
+ aliases;
10
+ /** Brief single-line description */
11
+ summary;
12
+ /** Full command description */
13
+ description;
14
+ /** Whether command should be hidden from help */
15
+ hidden;
16
+ /** Group name for organizing commands in help */
17
+ group;
18
+ /** Parent command if this is a subcommand */
19
+ parent;
20
+ /** Child subcommands */
21
+ commands;
22
+ /** Positional arguments */
23
+ arguments;
24
+ /** Named options/flags */
25
+ options;
26
+ /** Help system configuration */
27
+ helpConfiguration;
8
28
  constructor(name = "", parent = null) {
9
- /** Command name used for invocation */
10
- __publicField(this, "name");
11
- /** Optional version string */
12
- __publicField(this, "version");
13
- /** Alternative names for this command */
14
- __publicField(this, "aliases");
15
- /** Brief single-line description */
16
- __publicField(this, "summary");
17
- /** Full command description */
18
- __publicField(this, "description");
19
- /** Whether command should be hidden from help */
20
- __publicField(this, "hidden");
21
- /** Group name for organizing commands in help */
22
- __publicField(this, "group");
23
- /** Parent command if this is a subcommand */
24
- __publicField(this, "parent");
25
- /** Child subcommands */
26
- __publicField(this, "commands");
27
- /** Positional arguments */
28
- __publicField(this, "arguments");
29
- /** Named options/flags */
30
- __publicField(this, "options");
31
- /** Help system configuration */
32
- __publicField(this, "helpConfiguration");
33
29
  this.name = name;
34
30
  this.parent = parent;
35
31
  this.aliases = [];
@@ -44,7 +40,7 @@ const _Command = class _Command {
44
40
  setState(state) {
45
41
  Object.assign(this, state);
46
42
  if (state.commands) {
47
- state.commands = state.commands.map((cmd) => new _Command(cmd.name, this).setState(cmd));
43
+ state.commands = state.commands.map((cmd) => new Command(cmd.name, this).setState(cmd));
48
44
  }
49
45
  return this;
50
46
  }
@@ -127,7 +123,7 @@ const _Command = class _Command {
127
123
  }
128
124
  /** Creates and adds a subcommand */
129
125
  subcommand(name) {
130
- const sub = new _Command(name, this);
126
+ const sub = new Command(name, this);
131
127
  this.commands.push(sub);
132
128
  return sub;
133
129
  }
@@ -426,10 +422,8 @@ const _Command = class _Command {
426
422
  renderHelp(help) {
427
423
  return this.createHelpAdapter().renderHelp(help);
428
424
  }
429
- };
430
- __name(_Command, "Command");
431
- let Command = _Command;
425
+ }
432
426
  export {
433
427
  Command
434
428
  };
435
- //# sourceMappingURL=Command.js.map
429
+ //# sourceMappingURL=Command.mjs.map
@@ -1,6 +1,5 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
3
  var __decorateClass = (decorators, target, key, kind) => {
5
4
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
6
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
@@ -77,7 +76,6 @@ const _CommandHelpAdapter = class _CommandHelpAdapter {
77
76
  return opt.type === "boolean" ? flags : opt.required ? opt.multiple ? flags + ` <${opt.argName}...>` : flags + ` <${opt.argName}>` : opt.multiple ? flags + ` [${opt.argName}...]` : flags + ` [${opt.argName}]`;
78
77
  }
79
78
  };
80
- __name(_CommandHelpAdapter, "CommandHelpAdapter");
81
79
  __decorateClass([
82
80
  lazyProp
83
81
  ], _CommandHelpAdapter.prototype, "usage", 1);
@@ -97,4 +95,4 @@ let CommandHelpAdapter = _CommandHelpAdapter;
97
95
  export {
98
96
  CommandHelpAdapter
99
97
  };
100
- //# sourceMappingURL=CommandHelpAdapter.js.map
98
+ //# sourceMappingURL=CommandHelpAdapter.mjs.map
@@ -1,6 +1,5 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
3
  var __decorateClass = (decorators, target, key, kind) => {
5
4
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
6
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
@@ -64,7 +63,6 @@ const _CommanderHelpAdapter = class _CommanderHelpAdapter {
64
63
  return { ...this.cmd.configureHelp() };
65
64
  }
66
65
  };
67
- __name(_CommanderHelpAdapter, "CommanderHelpAdapter");
68
66
  __decorateClass([
69
67
  lazyProp
70
68
  ], _CommanderHelpAdapter.prototype, "summary", 1);
@@ -87,4 +85,4 @@ let CommanderHelpAdapter = _CommanderHelpAdapter;
87
85
  export {
88
86
  CommanderHelpAdapter
89
87
  };
90
- //# sourceMappingURL=CommanderHelpAdapter.js.map
88
+ //# sourceMappingURL=CommanderHelpAdapter.mjs.map
@@ -1,16 +1,10 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- const _Help = class _Help {
6
- constructor() {
7
- /** output helpWidth, long lines are wrapped to fit */
8
- __publicField(this, "helpWidth", process.stdout.isTTY ? process.stdout.columns : 80);
9
- __publicField(this, "minWidthToWrap", 40);
10
- __publicField(this, "sortSubcommands");
11
- __publicField(this, "sortOptions");
12
- __publicField(this, "showGlobalOptions");
13
- }
1
+ class Help {
2
+ /** output helpWidth, long lines are wrapped to fit */
3
+ helpWidth = process.stdout.isTTY ? process.stdout.columns : 80;
4
+ minWidthToWrap = 40;
5
+ sortSubcommands;
6
+ sortOptions;
7
+ showGlobalOptions;
14
8
  /**
15
9
  * Get an array of the visible subcommands. Includes a placeholder for the implicit help command, if there is one.
16
10
  */
@@ -27,9 +21,9 @@ const _Help = class _Help {
27
21
  * Compare options for sort.
28
22
  */
29
23
  compareOptions(a, b) {
30
- const getSortKey = /* @__PURE__ */ __name((option) => {
24
+ const getSortKey = (option) => {
31
25
  return option.short ? option.short.replace(/^-/, "") : option.long.replace(/^--/, "");
32
- }, "getSortKey");
26
+ };
33
27
  return getSortKey(a).localeCompare(getSortKey(b));
34
28
  }
35
29
  /**
@@ -232,7 +226,6 @@ const _Help = class _Help {
232
226
  function callFormatItem(term, description) {
233
227
  return helper.formatItem(term, termWidth, description, helper);
234
228
  }
235
- __name(callFormatItem, "callFormatItem");
236
229
  let output = [`${helper.styleTitle("Usage:")} ${helper.styleUsage(helper.commandUsage(cmd))}`, ""];
237
230
  const commandDescription = helper.commandDescription(cmd);
238
231
  if (commandDescription.length > 0) {
@@ -458,20 +451,16 @@ ${itemIndentStr}`);
458
451
  });
459
452
  return wrappedLines.join("\n");
460
453
  }
461
- };
462
- __name(_Help, "Help");
463
- let Help = _Help;
454
+ }
464
455
  function stripColor(str) {
465
456
  const sgrPattern = /\x1b\[\d*(;\d*)*m/g;
466
457
  return str.replace(sgrPattern, "");
467
458
  }
468
- __name(stripColor, "stripColor");
469
459
  function humanReadableArgName(arg) {
470
460
  const nameOutput = arg.name + (arg.variadic === true ? "..." : "");
471
461
  return arg.required ? "<" + nameOutput + ">" : "[" + nameOutput + "]";
472
462
  }
473
- __name(humanReadableArgName, "humanReadableArgName");
474
463
  export {
475
464
  Help
476
465
  };
477
- //# sourceMappingURL=Help.js.map
466
+ //# sourceMappingURL=Help.mjs.map
@@ -1,5 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
1
  function lazyProp(target, key, descriptor) {
4
2
  const orig = descriptor.get;
5
3
  if (typeof orig !== "function") {
@@ -17,8 +15,7 @@ function lazyProp(target, key, descriptor) {
17
15
  };
18
16
  return descriptor;
19
17
  }
20
- __name(lazyProp, "lazyProp");
21
18
  export {
22
19
  lazyProp as default
23
20
  };
24
- //# sourceMappingURL=lazyProp.js.map
21
+ //# sourceMappingURL=lazyProp.mjs.map
@@ -1,12 +1,9 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
1
  import { Help } from "./Help";
4
2
  function renderHelp(cmd, help = new Help()) {
5
3
  const helper = Object.assign(help, cmd.helpConfiguration);
6
4
  return helper.formatHelp(cmd, helper);
7
5
  }
8
- __name(renderHelp, "renderHelp");
9
6
  export {
10
7
  renderHelp
11
8
  };
12
- //# sourceMappingURL=renderHelp.js.map
9
+ //# sourceMappingURL=renderHelp.mjs.map
package/package.json CHANGED
@@ -1,19 +1,13 @@
1
1
  {
2
2
  "name": "@bemoje/cli",
3
3
  "description": "A type-safe CLI builder focused on command composition and help generation without execution coupling. Parse arguments, generate help, and integrate with existing CLI frameworks through a clean, fluent API.",
4
- "version": "1.0.2",
4
+ "version": "1.0.4",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "type": "module",
8
- "module": "./index.js",
9
- "main": "./index.js",
10
- "exports": {
11
- ".": "./index.js",
12
- "./*": "./lib/*.js",
13
- "./package.json": "./package.json",
14
- "./index.d.ts": "./index.d.ts"
15
- },
16
- "typings": "./index.d.ts",
8
+ "module": "./esm/index.mjs",
9
+ "main": "./cjs/index.cjs",
10
+ "typings": "./typings/index.d.ts",
17
11
  "dependencies": {},
18
12
  "devDependencies": {
19
13
  "commander": "^14.0.0"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes