Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

## 0.17.2 — 07.10.2026

### 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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions src/pretty.test.ts
Original file line number Diff line number Diff line change
@@ -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")
})
})
7 changes: 7 additions & 0 deletions src/pretty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, unknown>

const palette = (color: boolean) => ({
Expand Down
Loading