From 6a206f12dfcb8a308b61eb4e36bee53ef3e599c8 Mon Sep 17 00:00:00 2001 From: leemour Date: Wed, 7 Oct 2026 00:14:09 +0200 Subject: [PATCH 1/2] feat(pretty): indent(text, spaces) for indented blocks on stderr tg-cli and max-cli print their setup steps as a flat list, and the QR code sits against the left edge. Both will indent a step's body and the QR code with one shared function, so the two setup screens stay alike. Empty lines stay empty, so the terminal gets no trailing spaces. Co-Authored-By: Claude Opus 5.5 (1M context) --- CHANGELOG.md | 7 +++++++ src/index.ts | 2 +- src/pretty.test.ts | 12 ++++++++++++ src/pretty.ts | 7 +++++++ 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/pretty.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 8132960..bac7e81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ Versions before 0.8.0 are in the [git tags](https://github.com/leemour/cli-core/ Every entry says what changed as a caller sees it, why, and what to watch for — the rules are [`docs/dev/CONVENTIONS.md`](docs/dev/CONVENTIONS.md#the-changelog). +## Unreleased + +### Added + +- **`indent(text, spaces)` shifts every line of a block right.** A step's body under its heading, or a + QR code, can sit indented in a setup screen. Empty lines stay empty, so no trailing spaces are printed. + ## 0.17.1 — 04.10.2026 ### Fixed diff --git a/src/index.ts b/src/index.ts index f98b907..1748132 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,7 +7,7 @@ export { brokenKeyring, type KeyringStore, memoryKeyring, systemKeyring } from " export { type Logger, noopLogger } from "./logger.js" export { createFileLogger, type FileLogger, type FileLoggerOptions, REDACTED_FIELDS } from "./logging.js" export { configFilePath, type Paths, type PathsOptions, pathsAreOverridden, resolvePaths } from "./paths.js" -export { type PrettyOptions, renderPretty } from "./pretty.js" +export { indent, type PrettyOptions, renderPretty } from "./pretty.js" export { createRenderer, RENDER_FORMATS, diff --git a/src/pretty.test.ts b/src/pretty.test.ts new file mode 100644 index 0000000..0529d38 --- /dev/null +++ b/src/pretty.test.ts @@ -0,0 +1,12 @@ +import { describe, expect, it } from "vitest" +import { indent } from "./pretty.js" + +describe("indent", () => { + it("shifts every line and leaves empty lines empty", () => { + expect(indent("[1/5] Title\n\nbody", 2)).toBe(" [1/5] Title\n\n body") + }) + + it("leaves the text alone at zero", () => { + expect(indent("a\nb", 0)).toBe("a\nb") + }) +}) diff --git a/src/pretty.ts b/src/pretty.ts index bf572d1..5efd60b 100644 --- a/src/pretty.ts +++ b/src/pretty.ts @@ -32,6 +32,13 @@ export const renderPretty = (value: unknown, options: PrettyOptions): string => return renderJson(value) } +/** Shifts every line right; an empty line stays empty, so no trailing spaces reach the terminal. */ +export const indent = (text: string, spaces: number): string => + text + .split("\n") + .map((line) => (line === "" ? line : `${" ".repeat(spaces)}${line}`)) + .join("\n") + type Row = Record const palette = (color: boolean) => ({ From 85a79a5f9ecf30afda182bf8724d58e86cde3819 Mon Sep 17 00:00:00 2001 From: leemour Date: Wed, 7 Oct 2026 00:18:56 +0200 Subject: [PATCH 2/2] chore: release cli-core 0.17.2 Co-Authored-By: Claude Opus 5.5 (1M context) --- CHANGELOG.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bac7e81..ae4893f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ Versions before 0.8.0 are in the [git tags](https://github.com/leemour/cli-core/ Every entry says what changed as a caller sees it, why, and what to watch for — the rules are [`docs/dev/CONVENTIONS.md`](docs/dev/CONVENTIONS.md#the-changelog). -## Unreleased +## 0.17.2 — 07.10.2026 ### Added diff --git a/package.json b/package.json index 1da3315..1ff1d6f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@leemour/cli-core", - "version": "0.17.1", + "version": "0.17.2", "description": "The parts every command line tool needs: output modes, terminal rendering, error model, exit codes, credentials, clocks", "license": "MIT", "author": "Viacheslav Ptsarev",