@nmakarov/cli-toolkit 0.27.0 → 0.32.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/dist/init.js CHANGED
@@ -1734,7 +1734,8 @@ var Params = class _Params {
1734
1734
  /**
1735
1735
  * Resolved early in constructor so cleanup does not read params lazily.
1736
1736
  * One of: false (off) | "end" (print at exit) | "top" (print after init,
1737
- * via context.showUsedParamsIfNeeded()).
1737
+ * via context.showUsedParamsIfNeeded()) | "stop" (print after init, then
1738
+ * exit the process — also via context.showUsedParamsIfNeeded()).
1738
1739
  */
1739
1740
  _showUsedParamsMode = false;
1740
1741
  /** Guard so the dump prints at most once (top OR end, never both). */
@@ -1758,8 +1759,9 @@ var Params = class _Params {
1758
1759
  * (absent) / --no-showUsedParams / =false -> false (off)
1759
1760
  * --showUsedParams / =true -> "end" (print at exit)
1760
1761
  * --showUsedParams=top -> "top" (print after init)
1761
- * Read raw (uncoerced) from args so the string "top" isn't forced to a
1762
- * boolean, then track it under the "script" module for the dump itself.
1762
+ * --showUsedParams=stop -> "stop" (print after init, then exit)
1763
+ * Read raw (uncoerced) from args so the string "top"/"stop" isn't forced to
1764
+ * a boolean, then track it under the "script" module for the dump itself.
1763
1765
  */
1764
1766
  _resolveShowUsedParams() {
1765
1767
  const raw = this.args.get("showUsedParams");
@@ -1769,6 +1771,8 @@ var Params = class _Params {
1769
1771
  mode = false;
1770
1772
  } else if (typeof raw === "string" && raw.trim().toLowerCase() === "top") {
1771
1773
  mode = "top";
1774
+ } else if (typeof raw === "string" && raw.trim().toLowerCase() === "stop") {
1775
+ mode = "stop";
1772
1776
  } else {
1773
1777
  const s = typeof raw === "string" ? raw.trim().toLowerCase() : raw;
1774
1778
  const falsey = s === false || s === "false" || s === "0" || s === "no" || s === "off";
@@ -1782,7 +1786,7 @@ var Params = class _Params {
1782
1786
  getShowUsedParams() {
1783
1787
  return this._showUsedParamsMode !== false;
1784
1788
  }
1785
- /** Resolved mode: false | "end" | "top". */
1789
+ /** Resolved mode: false | "end" | "top" | "stop". */
1786
1790
  getShowUsedParamsMode() {
1787
1791
  return this._showUsedParamsMode;
1788
1792
  }
@@ -2497,9 +2501,18 @@ function setup(opts = {}) {
2497
2501
  // the used-params list now (after the script has initialized all its
2498
2502
  // own components), instead of at exit. No-op for the default mode,
2499
2503
  // which prints at exit via the cleanup registered by Params.
2504
+ //
2505
+ // --showUsedParams=stop behaves like "top" but then exits immediately —
2506
+ // a quick "show me the figured params and quit" that skips the flow's
2507
+ // actual work. Like --stopAfter=init, this is a hard exit(0) (registered
2508
+ // cleanups are skipped); call it once components/params are resolved.
2500
2509
  showUsedParamsIfNeeded: () => {
2501
- if (params.getShowUsedParamsMode?.() === "top") {
2502
- params.printUsedParams(logger);
2510
+ const mode = params.getShowUsedParamsMode?.();
2511
+ if (mode !== "top" && mode !== "stop") return;
2512
+ params.printUsedParams(logger);
2513
+ if (mode === "stop") {
2514
+ logger.debug?.("[showUsedParams=stop] params printed \u2014 exiting");
2515
+ process.exit(0);
2503
2516
  }
2504
2517
  }
2505
2518
  };