@zinn-dev/cli 0.30.0 → 0.31.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/README.md
CHANGED
|
@@ -144,7 +144,7 @@ Label names preserve their stored casing, but matching and uniqueness are case-i
|
|
|
144
144
|
|
|
145
145
|
Descriptions default to an empty string and the label colors default to white. Available colors are _red_, _green_, _yellow_, _blue_, _magenta_, _cyan_, _white_, and _gray_.
|
|
146
146
|
|
|
147
|
-
`label create` and `label list` print each label name in its color. `--json` output shows the color as a value
|
|
147
|
+
`label create`, `label edit` and `label list` print each label name in its color. When color is off (see [Scripting and JSON output](#scripting-and-json-output)), they name the color instead, such as `bug | red | Broken`. `--json` output always shows the color as a value.
|
|
148
148
|
|
|
149
149
|
`label edit` changes only the supplied name, color, or description. Renaming preserves every task attachment because attachments refer to the label's internal ID. Also, updating a label does not affect any tasks' timestamps that it is attached to.
|
|
150
150
|
|
|
@@ -276,7 +276,7 @@ zinn task create MDR --title "Refine the numbers" --json
|
|
|
276
276
|
- Output is a single JSON document on stdout. Empty lists print `[]`.
|
|
277
277
|
- Errors go to stderr as `{ "error": { "message": "..." } }`, stdout stays empty, and the command exits with code 1.
|
|
278
278
|
|
|
279
|
-
Text output is
|
|
279
|
+
Text output is mainly for _visual_ consumption. Colors appear only when the output goes to a terminal and [`NO_COLOR`](https://no-color.org/) is unset or empty. Piped text is plain, but its layout may change between versions. Scripts should use `--json` to get reliable output.
|
|
280
280
|
|
|
281
281
|
### Confirmations
|
|
282
282
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { styleText } from "node:util";
|
|
2
|
+
|
|
3
|
+
type StyleFormat = Parameters<typeof styleText>[0];
|
|
4
|
+
|
|
5
|
+
// Bun's styleText emits ANSI even when stdout is piped or NO_COLOR is set, so Zinn decides when to color.
|
|
6
|
+
// Following https://no-color.org/, any non-empty NO_COLOR value turns color off.
|
|
7
|
+
export function isColorEnabled() {
|
|
8
|
+
const isNoColorSet = (process.env.NO_COLOR ?? "").length > 0;
|
|
9
|
+
|
|
10
|
+
return process.stdout.isTTY === true && !isNoColorSet;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function styleOutputText(format: StyleFormat, text: string) {
|
|
14
|
+
if (!isColorEnabled()) {
|
|
15
|
+
return text;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return styleText(format, text);
|
|
19
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { TaskPriority, TaskWithKey } from "@zinn-dev/core";
|
|
2
2
|
|
|
3
|
-
import { styleText } from "node:util";
|
|
4
3
|
import { column, task } from "@zinn-dev/core";
|
|
5
4
|
|
|
6
5
|
import { TASK_DESCRIPTION_PREVIEW_LENGTH } from "../constant";
|
|
6
|
+
import { styleOutputText } from "./color";
|
|
7
7
|
|
|
8
8
|
function formatTaskDescriptionPreview(description: string | null) {
|
|
9
9
|
if (description == null) {
|
|
@@ -42,11 +42,11 @@ export function formatTaskColumn(columnName: string, width = columnName.length)
|
|
|
42
42
|
|
|
43
43
|
// TODO: Derive column colors from column roles once roles exist instead of relying on names.
|
|
44
44
|
if (columnName === "Backlog") {
|
|
45
|
-
return
|
|
45
|
+
return styleOutputText("gray", paddedColumnName);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
if (columnName === "Done") {
|
|
49
|
-
return
|
|
49
|
+
return styleOutputText("green", paddedColumnName);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
return paddedColumnName;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Label } from "@zinn-dev/core";
|
|
2
2
|
import type { RouteDef } from "../types";
|
|
3
3
|
|
|
4
|
-
import { parseArgs
|
|
4
|
+
import { parseArgs } from "node:util";
|
|
5
5
|
import { label, labelCreateSchema, labelDeleteSchema, labelEditSchema } from "@zinn-dev/core";
|
|
6
6
|
|
|
7
7
|
import {
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
validateUniqueOptions,
|
|
13
13
|
} from "../lib";
|
|
14
14
|
import { currentActor } from "../actor";
|
|
15
|
+
import { isColorEnabled, styleOutputText } from "../presentation/color";
|
|
15
16
|
|
|
16
17
|
type PresentedLabel = Omit<Label, "id">;
|
|
17
18
|
|
|
@@ -20,13 +21,16 @@ function presentLabel(labelMatch: Label): PresentedLabel {
|
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
function formatLabel(presented: PresentedLabel) {
|
|
23
|
-
|
|
24
|
+
// The colored name shows the color; without color, the color is named instead.
|
|
25
|
+
const name = isColorEnabled()
|
|
26
|
+
? styleOutputText(presented.color, presented.name)
|
|
27
|
+
: `${presented.name} | ${presented.color}`;
|
|
24
28
|
|
|
25
29
|
if (presented.description.length === 0) {
|
|
26
|
-
return
|
|
30
|
+
return name;
|
|
27
31
|
}
|
|
28
32
|
|
|
29
|
-
return `${
|
|
33
|
+
return `${name} | ${presented.description}`;
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
export const labelRouter = {
|