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

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
@@ -44,26 +44,13 @@ function printError(message, options = {}) {
44
44
  const output = node_process.default[stream];
45
45
  const quotes = options.quotes ?? !output.isTTY;
46
46
  const colors = options.colors ?? output.isTTY;
47
- const useColors = typeof colors === "object" ? true : colors;
48
- const maxWidth = options.maxWidth ?? output.columns;
49
- const occupied = options.initialWidth ?? 0;
50
- if (!Number.isFinite(occupied) || !Number.isInteger(occupied)) throw new TypeError("Initial width must be a finite integer.");
51
- if (occupied < 0) throw new RangeError("Initial width must be nonnegative.");
52
- let prefix = (0, __optique_core_internal_terminal.renderTerminalTerm)({
53
- type: "errorLabel",
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);
59
- const formatMessage = (0, __optique_core_internal_terminal.resolveMessageFormatter)(options);
60
- const formatted = formatMessage(message, {
47
+ const formatted = (0, __optique_core_internal_terminal.renderErrorMessage)(message, {
48
+ ...options,
61
49
  colors,
62
50
  quotes,
63
- maxWidth,
64
- initialWidth
51
+ maxWidth: options.maxWidth ?? output.columns
65
52
  });
66
- output.write(prefix + formatted + "\n");
53
+ output.write(formatted + "\n");
67
54
  if (options.exitCode != null) node_process.default.exit(options.exitCode);
68
55
  }
69
56
  /**
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 { renderErrorMessage, resolveMessageFormatter } from "@optique/core/internal/terminal";
3
3
 
4
4
  //#region src/print.ts
5
5
  /**
@@ -43,26 +43,13 @@ function printError(message, options = {}) {
43
43
  const output = process[stream];
44
44
  const quotes = options.quotes ?? !output.isTTY;
45
45
  const colors = options.colors ?? output.isTTY;
46
- const useColors = typeof colors === "object" ? true : colors;
47
- const maxWidth = options.maxWidth ?? output.columns;
48
- const occupied = options.initialWidth ?? 0;
49
- if (!Number.isFinite(occupied) || !Number.isInteger(occupied)) throw new TypeError("Initial width must be a finite integer.");
50
- if (occupied < 0) throw new RangeError("Initial width must be nonnegative.");
51
- let prefix = renderTerminalTerm({
52
- type: "errorLabel",
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);
58
- const formatMessage = resolveMessageFormatter(options);
59
- const formatted = formatMessage(message, {
46
+ const formatted = renderErrorMessage(message, {
47
+ ...options,
60
48
  colors,
61
49
  quotes,
62
- maxWidth,
63
- initialWidth
50
+ maxWidth: options.maxWidth ?? output.columns
64
51
  });
65
- output.write(prefix + formatted + "\n");
52
+ output.write(formatted + "\n");
66
53
  if (options.exitCode != null) process.exit(options.exitCode);
67
54
  }
68
55
  /**
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.2558",
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.2558+85f681ee"
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.2558+85f681ee",
83
+ "@optique/env": "1.3.0-dev.2558+85f681ee",
84
84
  "@types/node": "^24.0.0",
85
85
  "fast-check": "^4.7.0",
86
86
  "tsdown": "^0.13.0",