rename klo to ktx

This commit is contained in:
Andrey Avtomonov 2026-05-10 23:51:24 +02:00
parent 1a42152e6f
commit 3ce510b55b
704 changed files with 10205 additions and 10255 deletions

View file

@ -1,8 +1,8 @@
import { describe, expect, it } from 'vitest';
import type { KloCliIo } from '../cli-runtime.js';
import type { KtxCliIo } from '../cli-runtime.js';
import { resolveOutputMode } from './mode.js';
function ioWith(isTTY: boolean | undefined): KloCliIo {
function ioWith(isTTY: boolean | undefined): KtxCliIo {
return {
stdout: { isTTY, write: () => {} },
stderr: { write: () => {} },
@ -24,14 +24,14 @@ describe('resolveOutputMode', () => {
expect(() => resolveOutputMode({ explicit: 'fancy', io: ioWith(true), env: {} })).toThrow(/Invalid --output/);
});
it('honors KLO_OUTPUT env var when no explicit value', () => {
expect(resolveOutputMode({ io: ioWith(true), env: { KLO_OUTPUT: 'plain' } })).toBe('plain');
expect(resolveOutputMode({ io: ioWith(false), env: { KLO_OUTPUT: 'pretty' } })).toBe('pretty');
expect(resolveOutputMode({ io: ioWith(false), env: { KLO_OUTPUT: 'json' } })).toBe('json');
it('honors KTX_OUTPUT env var when no explicit value', () => {
expect(resolveOutputMode({ io: ioWith(true), env: { KTX_OUTPUT: 'plain' } })).toBe('plain');
expect(resolveOutputMode({ io: ioWith(false), env: { KTX_OUTPUT: 'pretty' } })).toBe('pretty');
expect(resolveOutputMode({ io: ioWith(false), env: { KTX_OUTPUT: 'json' } })).toBe('json');
});
it('throws on unknown KLO_OUTPUT', () => {
expect(() => resolveOutputMode({ io: ioWith(true), env: { KLO_OUTPUT: 'fancy' } })).toThrow(/Invalid KLO_OUTPUT/);
it('throws on unknown KTX_OUTPUT', () => {
expect(() => resolveOutputMode({ io: ioWith(true), env: { KTX_OUTPUT: 'fancy' } })).toThrow(/Invalid KTX_OUTPUT/);
});
it('returns plain when CI is set to a truthy value', () => {
@ -54,7 +54,7 @@ describe('resolveOutputMode', () => {
expect(resolveOutputMode({ io: ioWith(undefined), env: {} })).toBe('plain');
});
it('explicit value beats KLO_OUTPUT env var', () => {
expect(resolveOutputMode({ explicit: 'json', io: ioWith(true), env: { KLO_OUTPUT: 'plain' } })).toBe('json');
it('explicit value beats KTX_OUTPUT env var', () => {
expect(resolveOutputMode({ explicit: 'json', io: ioWith(true), env: { KTX_OUTPUT: 'plain' } })).toBe('json');
});
});

View file

@ -1,17 +1,17 @@
import type { KloCliIo } from '../cli-runtime.js';
import type { KtxCliIo } from '../cli-runtime.js';
export type KloOutputMode = 'pretty' | 'plain' | 'json';
export type KtxOutputMode = 'pretty' | 'plain' | 'json';
const MODES: ReadonlySet<string> = new Set(['pretty', 'plain', 'json']);
export interface ResolveOutputModeArgs {
explicit?: string;
json?: boolean;
io: KloCliIo;
io: KtxCliIo;
env?: NodeJS.ProcessEnv;
}
export function resolveOutputMode(args: ResolveOutputModeArgs): KloOutputMode {
export function resolveOutputMode(args: ResolveOutputModeArgs): KtxOutputMode {
if (args.json === true) {
return 'json';
}
@ -19,15 +19,15 @@ export function resolveOutputMode(args: ResolveOutputModeArgs): KloOutputMode {
if (!MODES.has(args.explicit)) {
throw new Error(`Invalid --output value: ${args.explicit}. Expected one of pretty, plain, json.`);
}
return args.explicit as KloOutputMode;
return args.explicit as KtxOutputMode;
}
const env = args.env ?? process.env;
const envMode = env.KLO_OUTPUT;
const envMode = env.KTX_OUTPUT;
if (envMode !== undefined && envMode !== '') {
if (!MODES.has(envMode)) {
throw new Error(`Invalid KLO_OUTPUT value: ${envMode}. Expected one of pretty, plain, json.`);
throw new Error(`Invalid KTX_OUTPUT value: ${envMode}. Expected one of pretty, plain, json.`);
}
return envMode as KloOutputMode;
return envMode as KtxOutputMode;
}
const ci = env.CI;
if (ci !== undefined && ci !== '' && ci !== '0' && ci !== 'false') {

View file

@ -1,9 +1,9 @@
import { describe, expect, it } from 'vitest';
import type { KloCliIo } from '../cli-runtime.js';
import type { KtxCliIo } from '../cli-runtime.js';
import { printList, type PrintListColumn } from './print-list.js';
import { SYMBOLS } from './symbols.js';
function recorder(): { io: KloCliIo; out: () => string; err: () => string } {
function recorder(): { io: KtxCliIo; out: () => string; err: () => string } {
let stdout = '';
let stderr = '';
return {

View file

@ -1,5 +1,5 @@
import type { KloCliIo } from '../cli-runtime.js';
import type { KloOutputMode } from './mode.js';
import type { KtxCliIo } from '../cli-runtime.js';
import type { KtxOutputMode } from './mode.js';
import { bold, dim, SYMBOLS } from './symbols.js';
export interface PrintListColumn<Row> {
@ -24,8 +24,8 @@ export interface PrintListArgs<Row> {
groupBy?: keyof Row & string;
emptyMessage: string;
command: string;
mode: KloOutputMode;
io: KloCliIo;
mode: KtxOutputMode;
io: KtxCliIo;
}
export function printList<Row extends object>(args: PrintListArgs<Row>): void {