@effected/cli 0.20.0 → 0.21.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/Fmt.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { displayWidth, graphemes, stripAnsi } from "./internal/displayWidth.js";
2
+ import { Duration, Option } from "effect";
2
3
 
3
4
  // src/Fmt.ts
4
5
  const CONTROL = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F]/g;
@@ -76,18 +77,27 @@ var Fmt = class {
76
77
  return useEllipsis ? `${out}${ellipsis}` : out;
77
78
  };
78
79
  /**
79
- * A duration in milliseconds as short human text: `250ms`, `1.2s`, `2s`, `1m 3s`, `2m`, `1h 2m`, `2h`.
80
+ * A duration as short human text: `250ms`, `1.2s`, `2s`, `1m 3s`, `2m`, `1h 2m`, `2h`.
80
81
  *
81
82
  * @remarks
82
83
  * Under a second it is whole milliseconds; under a minute, seconds to one decimal with a trailing `.0`
83
84
  * dropped; under an hour, minutes and whole seconds, with the seconds dropped when zero; from an hour, hours and
84
85
  * whole minutes, the seconds dropped. A value that rounds up to the next unit (`999.6` to a second, `59999` to a
85
86
  * minute, `3599999` to an hour) is written in that unit, so `1000ms`, `60s` and `60m` never appear. There is no
86
- * days unit. A negative or non-finite input is `0ms`.
87
+ * days unit. The format is bespoke: core's `Duration.format` renders differently.
87
88
  *
88
- * @param ms - the duration in milliseconds
89
+ * The input is anything `Duration.Input` admits. A plain number is milliseconds and is used as given, never
90
+ * converted through a `Duration`, which rounds a fractional millisecond to whole nanoseconds and would move a value
91
+ * such as `999.4999999` across the rounding boundary. A `bigint` is nanoseconds, as in core. A negative, infinite
92
+ * or invalid input (a string `Duration.Input` cannot parse) is `0ms`: a formatter in a render path never throws.
93
+ *
94
+ * @param input - the duration; a number is milliseconds
89
95
  */
90
- static duration = (ms) => {
96
+ static duration = (input) => {
97
+ const ms = typeof input === "number" ? input : Option.match(Duration.fromInput(input), {
98
+ onNone: () => 0,
99
+ onSome: Duration.toMillis
100
+ });
91
101
  const value = Number.isFinite(ms) ? Math.max(0, ms) : 0;
92
102
  const whole = Math.round(value);
93
103
  if (whole < 1e3) return `${whole}ms`;
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Array as Array$1, Cause, Context, Effect, FileSystem, Layer, LogLevel, Logger, MutableRef, Option, Path, Runtime, Schema, Stdio, Terminal } from "effect";
1
+ import { Array as Array$1, Cause, Context, Duration, Effect, FileSystem, Layer, LogLevel, Logger, MutableRef, Option, Path, Runtime, Schema, Stdio, Terminal } from "effect";
2
2
  import { Audience, AudienceKind, ColorLevel, CurrentRuntimeEnv, RuntimeEnv, TerminalEnv } from "@effected/env";
3
3
  import { CliError, CliOutput, Command, Flag, Param, Prompt } from "effect/cli";
4
4
  import { ConfigValidationError } from "@effected/config-file";
@@ -3025,18 +3025,23 @@ export declare class Fmt {
3025
3025
  */
3026
3026
  static readonly truncate: (text: string, width: number, options?: TruncateOptions) => string;
3027
3027
  /**
3028
- * A duration in milliseconds as short human text: `250ms`, `1.2s`, `2s`, `1m 3s`, `2m`, `1h 2m`, `2h`.
3028
+ * A duration as short human text: `250ms`, `1.2s`, `2s`, `1m 3s`, `2m`, `1h 2m`, `2h`.
3029
3029
  *
3030
3030
  * @remarks
3031
3031
  * Under a second it is whole milliseconds; under a minute, seconds to one decimal with a trailing `.0`
3032
3032
  * dropped; under an hour, minutes and whole seconds, with the seconds dropped when zero; from an hour, hours and
3033
3033
  * whole minutes, the seconds dropped. A value that rounds up to the next unit (`999.6` to a second, `59999` to a
3034
3034
  * minute, `3599999` to an hour) is written in that unit, so `1000ms`, `60s` and `60m` never appear. There is no
3035
- * days unit. A negative or non-finite input is `0ms`.
3035
+ * days unit. The format is bespoke: core's `Duration.format` renders differently.
3036
3036
  *
3037
- * @param ms - the duration in milliseconds
3037
+ * The input is anything `Duration.Input` admits. A plain number is milliseconds and is used as given, never
3038
+ * converted through a `Duration`, which rounds a fractional millisecond to whole nanoseconds and would move a value
3039
+ * such as `999.4999999` across the rounding boundary. A `bigint` is nanoseconds, as in core. A negative, infinite
3040
+ * or invalid input (a string `Duration.Input` cannot parse) is `0ms`: a formatter in a render path never throws.
3041
+ *
3042
+ * @param input - the duration; a number is milliseconds
3038
3043
  */
3039
- static readonly duration: (ms: number) => string;
3044
+ static readonly duration: (input: Duration.Input) => string;
3040
3045
  /**
3041
3046
  * A ratio from 0 to 1 as a percentage, or a number already from 0 to 100 with `scale: 100`: `83.3%`, `50%`,
3042
3047
  * `100%`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effected/cli",
3
- "version": "0.20.0",
3
+ "version": "0.21.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": [
@@ -57,10 +57,10 @@
57
57
  "./package.json": "./package.json"
58
58
  },
59
59
  "dependencies": {
60
- "@effected/github-commands": "^0.6.0"
60
+ "@effected/github-commands": "^0.6.1"
61
61
  },
62
62
  "peerDependencies": {
63
- "@effected/config-file": "^0.18.0",
63
+ "@effected/config-file": "^0.19.0",
64
64
  "@effected/env": "^0.5.0",
65
65
  "@effected/glob": "^0.14.0",
66
66
  "@effected/walker": "^0.19.0",
package/ui/CliUi.js CHANGED
@@ -306,7 +306,7 @@ var CliUi = class CliUi {
306
306
  * so core renders its own message and `CliRuntime.main` exits `64`. Name the parameter with `flag` (the name
307
307
  * without dashes) or `argument` so that error can be built.
308
308
  *
309
- * The options are {@link @effected/cli!CliPromptFallbackOptions}, the same as `CliPrompt.fallback`'s, and `clear`
309
+ * The options are `CliPromptFallbackOptions` (from `@effected/cli`), the same as `CliPrompt.fallback`'s, and `clear`
310
310
  * as for {@link CliUi.run}.
311
311
  *
312
312
  * It runs during parsing, whose environment is core's alone, so it reads `CliTheme` if one is there: with
package/ui/UiKey.js CHANGED
@@ -5,7 +5,7 @@ const named = (name) => ({
5
5
  });
6
6
  const CONTROL = /[\u0000-\u001f\u007f]/;
7
7
  /**
8
- * Normalising Ink's input into {@link UiKey}s.
8
+ * Normalising Ink's input into {@link (UiKey:type)}s.
9
9
  *
10
10
  * @public
11
11
  */
package/ui.d.ts CHANGED
@@ -484,7 +484,7 @@ export declare class CliUi {
484
484
  * so core renders its own message and `CliRuntime.main` exits `64`. Name the parameter with `flag` (the name
485
485
  * without dashes) or `argument` so that error can be built.
486
486
  *
487
- * The options are {@link @effected/cli!CliPromptFallbackOptions}, the same as `CliPrompt.fallback`'s, and `clear`
487
+ * The options are `CliPromptFallbackOptions` (from `@effected/cli`), the same as `CliPrompt.fallback`'s, and `clear`
488
488
  * as for {@link CliUi.run}.
489
489
  *
490
490
  * It runs during parsing, whose environment is core's alone, so it reads `CliTheme` if one is there: with
@@ -619,7 +619,7 @@ export type UiKey = {
619
619
  readonly char: string;
620
620
  };
621
621
  /**
622
- * Normalising Ink's input into {@link UiKey}s.
622
+ * Normalising Ink's input into {@link (UiKey:type)}s.
623
623
  *
624
624
  * @public
625
625
  */
@@ -1517,8 +1517,8 @@ interface TextInputScreenOptions {
1517
1517
  * does the scrollback; erase the frame as well with `clear: true` on the run when even the mask's length should not
1518
1518
  * stay behind.
1519
1519
  *
1520
- * The message `validate` returns is drawn as it is, unmasked: a message that echoes the value (`"ghp_abc is a
1521
- * token"`) draws the secret in the frame. Say what is wrong without quoting the value.
1520
+ * The message `validate` returns is drawn as it is, unmasked: a message that echoes the value
1521
+ * (`"ghp_abc is a token"`) draws the secret in the frame. Say what is wrong without quoting the value.
1522
1522
  */
1523
1523
  readonly mask?: string | true | ((value: string) => boolean);
1524
1524
  }
@@ -1665,7 +1665,7 @@ declare const UiStreams_base: Context.Reference<UiStreamsShape>;
1665
1665
  */
1666
1666
  export declare class UiStreams extends UiStreams_base {}
1667
1667
  /**
1668
- * The styling props of an Ink `Text` that a {@link @effected/cli!Style} maps to.
1668
+ * The styling props of an Ink `Text` that a `Style` (from `@effected/cli`) maps to.
1669
1669
  *
1670
1670
  * @public
1671
1671
  */