@nmakarov/cli-toolkit 0.27.0 → 0.29.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.cjs CHANGED
@@ -1759,7 +1759,8 @@ var Params = class _Params {
1759
1759
  /**
1760
1760
  * Resolved early in constructor so cleanup does not read params lazily.
1761
1761
  * One of: false (off) | "end" (print at exit) | "top" (print after init,
1762
- * via context.showUsedParamsIfNeeded()).
1762
+ * via context.showUsedParamsIfNeeded()) | "stop" (print after init, then
1763
+ * exit the process — also via context.showUsedParamsIfNeeded()).
1763
1764
  */
1764
1765
  _showUsedParamsMode = false;
1765
1766
  /** Guard so the dump prints at most once (top OR end, never both). */
@@ -1783,8 +1784,9 @@ var Params = class _Params {
1783
1784
  * (absent) / --no-showUsedParams / =false -> false (off)
1784
1785
  * --showUsedParams / =true -> "end" (print at exit)
1785
1786
  * --showUsedParams=top -> "top" (print after init)
1786
- * Read raw (uncoerced) from args so the string "top" isn't forced to a
1787
- * boolean, then track it under the "script" module for the dump itself.
1787
+ * --showUsedParams=stop -> "stop" (print after init, then exit)
1788
+ * Read raw (uncoerced) from args so the string "top"/"stop" isn't forced to
1789
+ * a boolean, then track it under the "script" module for the dump itself.
1788
1790
  */
1789
1791
  _resolveShowUsedParams() {
1790
1792
  const raw = this.args.get("showUsedParams");
@@ -1794,6 +1796,8 @@ var Params = class _Params {
1794
1796
  mode = false;
1795
1797
  } else if (typeof raw === "string" && raw.trim().toLowerCase() === "top") {
1796
1798
  mode = "top";
1799
+ } else if (typeof raw === "string" && raw.trim().toLowerCase() === "stop") {
1800
+ mode = "stop";
1797
1801
  } else {
1798
1802
  const s = typeof raw === "string" ? raw.trim().toLowerCase() : raw;
1799
1803
  const falsey = s === false || s === "false" || s === "0" || s === "no" || s === "off";
@@ -1807,7 +1811,7 @@ var Params = class _Params {
1807
1811
  getShowUsedParams() {
1808
1812
  return this._showUsedParamsMode !== false;
1809
1813
  }
1810
- /** Resolved mode: false | "end" | "top". */
1814
+ /** Resolved mode: false | "end" | "top" | "stop". */
1811
1815
  getShowUsedParamsMode() {
1812
1816
  return this._showUsedParamsMode;
1813
1817
  }
@@ -2522,9 +2526,18 @@ function setup(opts = {}) {
2522
2526
  // the used-params list now (after the script has initialized all its
2523
2527
  // own components), instead of at exit. No-op for the default mode,
2524
2528
  // which prints at exit via the cleanup registered by Params.
2529
+ //
2530
+ // --showUsedParams=stop behaves like "top" but then exits immediately —
2531
+ // a quick "show me the figured params and quit" that skips the flow's
2532
+ // actual work. Like --stopAfter=init, this is a hard exit(0) (registered
2533
+ // cleanups are skipped); call it once components/params are resolved.
2525
2534
  showUsedParamsIfNeeded: () => {
2526
- if (params.getShowUsedParamsMode?.() === "top") {
2527
- params.printUsedParams(logger);
2535
+ const mode = params.getShowUsedParamsMode?.();
2536
+ if (mode !== "top" && mode !== "stop") return;
2537
+ params.printUsedParams(logger);
2538
+ if (mode === "stop") {
2539
+ logger.debug?.("[showUsedParams=stop] params printed \u2014 exiting");
2540
+ process.exit(0);
2528
2541
  }
2529
2542
  }
2530
2543
  };