@optique/run 1.3.0-dev.2542 → 1.3.0-dev.2554

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/print.cjs CHANGED
@@ -49,21 +49,21 @@ function printError(message, options = {}) {
49
49
  const occupied = options.initialWidth ?? 0;
50
50
  if (!Number.isFinite(occupied) || !Number.isInteger(occupied)) throw new TypeError("Initial width must be a finite integer.");
51
51
  if (occupied < 0) throw new RangeError("Initial width must be nonnegative.");
52
- let prefix = (0, __optique_core_internal_terminal.renderTerminalTerm)({
52
+ const prefix = (0, __optique_core_internal_terminal.placeText)((0, __optique_core_internal_terminal.spaceAfterLabel)((0, __optique_core_internal_terminal.renderTerminalTerm)({
53
53
  type: "errorLabel",
54
54
  label: "Error:"
55
- }, options.theme, useColors) + " ";
56
- if (maxWidth != null && occupied > 0 && occupied + (0, __optique_core_internal_terminal.getDisplayWidth)(prefix.split("\n")[0]) > maxWidth) prefix = "\n" + prefix;
57
- const prefixLines = prefix.split("\n");
58
- const initialWidth = (0, __optique_core_internal_terminal.getDisplayWidth)(prefixLines.at(-1) ?? "") + (prefixLines.length === 1 ? options.initialWidth ?? 0 : 0);
55
+ }, options.theme, useColors)), {
56
+ line: "",
57
+ column: occupied
58
+ }, maxWidth);
59
59
  const formatMessage = (0, __optique_core_internal_terminal.resolveMessageFormatter)(options);
60
60
  const formatted = formatMessage(message, {
61
61
  colors,
62
62
  quotes,
63
63
  maxWidth,
64
- initialWidth
64
+ initialWidth: prefix.cursor.column
65
65
  });
66
- output.write(prefix + formatted + "\n");
66
+ output.write(prefix.text + formatted + "\n");
67
67
  if (options.exitCode != null) node_process.default.exit(options.exitCode);
68
68
  }
69
69
  /**
package/dist/print.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import process from "node:process";
2
- import { getDisplayWidth, renderTerminalTerm, resolveMessageFormatter } from "@optique/core/internal/terminal";
2
+ import { placeText, renderTerminalTerm, resolveMessageFormatter, spaceAfterLabel } from "@optique/core/internal/terminal";
3
3
 
4
4
  //#region src/print.ts
5
5
  /**
@@ -48,21 +48,21 @@ function printError(message, options = {}) {
48
48
  const occupied = options.initialWidth ?? 0;
49
49
  if (!Number.isFinite(occupied) || !Number.isInteger(occupied)) throw new TypeError("Initial width must be a finite integer.");
50
50
  if (occupied < 0) throw new RangeError("Initial width must be nonnegative.");
51
- let prefix = renderTerminalTerm({
51
+ const prefix = placeText(spaceAfterLabel(renderTerminalTerm({
52
52
  type: "errorLabel",
53
53
  label: "Error:"
54
- }, options.theme, useColors) + " ";
55
- if (maxWidth != null && occupied > 0 && occupied + getDisplayWidth(prefix.split("\n")[0]) > maxWidth) prefix = "\n" + prefix;
56
- const prefixLines = prefix.split("\n");
57
- const initialWidth = getDisplayWidth(prefixLines.at(-1) ?? "") + (prefixLines.length === 1 ? options.initialWidth ?? 0 : 0);
54
+ }, options.theme, useColors)), {
55
+ line: "",
56
+ column: occupied
57
+ }, maxWidth);
58
58
  const formatMessage = resolveMessageFormatter(options);
59
59
  const formatted = formatMessage(message, {
60
60
  colors,
61
61
  quotes,
62
62
  maxWidth,
63
- initialWidth
63
+ initialWidth: prefix.cursor.column
64
64
  });
65
- output.write(prefix + formatted + "\n");
65
+ output.write(prefix.text + formatted + "\n");
66
66
  if (options.exitCode != null) process.exit(options.exitCode);
67
67
  }
68
68
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/run",
3
- "version": "1.3.0-dev.2542",
3
+ "version": "1.3.0-dev.2554",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",
@@ -76,11 +76,11 @@
76
76
  },
77
77
  "sideEffects": false,
78
78
  "dependencies": {
79
- "@optique/core": "1.3.0-dev.2542+1201b1a0"
79
+ "@optique/core": "1.3.0-dev.2554+5fdcbbad"
80
80
  },
81
81
  "devDependencies": {
82
- "@optique/config": "1.3.0-dev.2542+1201b1a0",
83
- "@optique/env": "1.3.0-dev.2542+1201b1a0",
82
+ "@optique/config": "1.3.0-dev.2554+5fdcbbad",
83
+ "@optique/env": "1.3.0-dev.2554+5fdcbbad",
84
84
  "@types/node": "^24.0.0",
85
85
  "fast-check": "^4.7.0",
86
86
  "tsdown": "^0.13.0",