@effected/cli 0.12.0 → 0.13.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/CliRuntime.js +4 -0
- package/index.d.ts +29 -5
- package/internal/renderMarkdown.js +1 -1
- package/package.json +2 -2
package/CliRuntime.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { Cancelled } from "./Cancelled.js";
|
|
1
2
|
import { sanitize } from "./Fmt.js";
|
|
3
|
+
import { NotInteractive } from "./NotInteractive.js";
|
|
2
4
|
import { FailureTargetCell, currentTarget, fallbackTarget, guardConsumerLines, linesOf, plainFailureLines, readSpans, refreshFailureTarget } from "./internal/failureTarget.js";
|
|
3
5
|
import { CliColor } from "./CliColor.js";
|
|
4
6
|
import { CliEnv } from "./CliEnv.js";
|
|
@@ -173,6 +175,8 @@ var CliRuntime = class CliRuntime {
|
|
|
173
175
|
const details = {
|
|
174
176
|
cause,
|
|
175
177
|
isDefect: !Cause.hasFails(cause),
|
|
178
|
+
isCancelled: error instanceof Cancelled,
|
|
179
|
+
isNotInteractive: error instanceof NotInteractive,
|
|
176
180
|
defaultLines,
|
|
177
181
|
lines: (options) => options?.status === false || options?.spans !== void 0 ? reportLines(options?.status !== false, options?.spans) : defaultLines
|
|
178
182
|
};
|
package/index.d.ts
CHANGED
|
@@ -2568,6 +2568,24 @@ interface FailureDetails {
|
|
|
2568
2568
|
* failure from the error channel.
|
|
2569
2569
|
*/
|
|
2570
2570
|
readonly isDefect: boolean;
|
|
2571
|
+
/**
|
|
2572
|
+
* `true` when the squashed `error` is the kit's {@link Cancelled}: the person quit a prompt or screen (Esc, Ctrl-C).
|
|
2573
|
+
* It is not a bug and there is nothing to report, whichever channel it arrived through.
|
|
2574
|
+
*
|
|
2575
|
+
* @remarks
|
|
2576
|
+
* A cancel from `CliPrompt.fallback` is a defect (`isDefect` is `true`) and one from `CliUi.run` is a typed failure
|
|
2577
|
+
* (`isDefect` is `false`), so a `render` that gives a defect the "please report this" treatment must test this flag
|
|
2578
|
+
* first, or Esc prints an issue-report request. `isDefect` keeps its plain meaning, the absence of a typed failure,
|
|
2579
|
+
* and the exit code is unchanged (`130` for the `interrupt` reason). `defaultLines` and `lines()` already draw it as
|
|
2580
|
+
* its one fixed line.
|
|
2581
|
+
*/
|
|
2582
|
+
readonly isCancelled: boolean;
|
|
2583
|
+
/**
|
|
2584
|
+
* `true` when the squashed `error` is the kit's {@link NotInteractive}: the program asked for a prompt or a screen in
|
|
2585
|
+
* a run that cannot show one (a pipe, an agent, a CI). It is a usage problem, not a bug, whichever channel it
|
|
2586
|
+
* arrived through; `isDefect` is as for {@link FailureDetails.isCancelled}.
|
|
2587
|
+
*/
|
|
2588
|
+
readonly isNotInteractive: boolean;
|
|
2571
2589
|
/**
|
|
2572
2590
|
* The report the kit writes for this failure when there is no `render`: for this run, in this audience, with its
|
|
2573
2591
|
* colour, links and `displayPath`. A `render` that hands a failure back returns these lines unchanged, and the
|
|
@@ -2687,9 +2705,11 @@ interface MainOptions<RP, EP> extends ReportFailuresOptions {
|
|
|
2687
2705
|
* one that writes output must use `Console` or `Stdio`, never `Terminal`.
|
|
2688
2706
|
*
|
|
2689
2707
|
* Stderr's colour mirrors stdout's terminal check unless `env.stderrIsTerminal` says otherwise, so with stderr
|
|
2690
|
-
* redirected and stdout a terminal the failure report is painted into the file. On Node, pass the real check
|
|
2691
|
-
*
|
|
2692
|
-
*
|
|
2708
|
+
* redirected and stdout a terminal the failure report is painted into the file. On Node, pass the real check from
|
|
2709
|
+
* the bin's entry, the one place it reads the host:
|
|
2710
|
+
* `env: { stderrIsTerminal: Effect.sync(() => process.stderr.isTTY === true) }`. Core's `Stdio` reports only
|
|
2711
|
+
* stdout (upstream Effect-TS/effect#8639); once core has a stderr check, this option reads it and the bin passes
|
|
2712
|
+
* nothing.
|
|
2693
2713
|
*/
|
|
2694
2714
|
readonly env?: CliEnvOptions | undefined;
|
|
2695
2715
|
/**
|
|
@@ -2706,8 +2726,12 @@ interface MainOptions<RP, EP> extends ReportFailuresOptions {
|
|
|
2706
2726
|
*
|
|
2707
2727
|
* Two cases keep help on stdout even under `"stderr"`. A `CliOutput`
|
|
2708
2728
|
* Formatter or a `Console` provided inside `program` is not seen by
|
|
2709
|
-
* `main`, so its help is not rerouted
|
|
2710
|
-
* `
|
|
2729
|
+
* `main`, so its help is not rerouted. To change the Formatter, pass
|
|
2730
|
+
* `env.formatter` (for example `formatVersion`): `main` installs its own
|
|
2731
|
+
* Formatter inside the platform, so that is the way in, and a Formatter
|
|
2732
|
+
* provided inside the program is invisible to the routing. A Formatter
|
|
2733
|
+
* the platform provides is shadowed by `main`'s, so pass it through
|
|
2734
|
+
* `env.formatter` as well. And with `Command.runWith`'s `renderErrors: false`
|
|
2711
2735
|
* no errors are printed, so nothing marks the help as a usage error's.
|
|
2712
2736
|
*/
|
|
2713
2737
|
readonly helpOnUsageError?: "stdout" | "stderr" | undefined;
|
|
@@ -52,7 +52,7 @@ const codeSpan = (text, mode) => {
|
|
|
52
52
|
const longest = Math.max(0, ...[...flat.matchAll(/`+/g)].map((run) => run[0].length));
|
|
53
53
|
const fence = "`".repeat(longest + 1);
|
|
54
54
|
const padded = /^`|`$/.test(flat) || /^ .* $/.test(flat) && flat.trim() !== "" || flat === "";
|
|
55
|
-
const body = mode === "cell" ? flat.
|
|
55
|
+
const body = mode === "cell" ? flat.split("|").join("\\|") : flat;
|
|
56
56
|
const pad = padded ? " " : "";
|
|
57
57
|
return `${fence}${pad}${body === "" ? " " : body}${pad}${fence}`;
|
|
58
58
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effected/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The presentation boundary of an effect/cli program: audience-aware output, a document IR and renderers, editor links, failure reports and logging, plus opt-in Ink screens, widgets and a live view",
|
|
6
6
|
"keywords": [
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@effected/github-commands": "^0.1.0"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
|
-
"@effected/config-file": "^0.14.
|
|
63
|
+
"@effected/config-file": "^0.14.2",
|
|
64
64
|
"@effected/env": "^0.1.0",
|
|
65
65
|
"@effected/glob": "^0.10.0",
|
|
66
66
|
"@effected/walker": "^0.15.0",
|