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
10 changes: 1 addition & 9 deletions cli/src/commands/round-tables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Command } from 'commander';
import { spawn } from 'child_process';
import { AdmpClient, AdmpError } from '../client.js';
import { requireConfig } from '../config.js';
import { success, error, warn, isJsonMode } from '../output.js';
import { success, error, warn, isJsonMode, green, yellow, cyan, bold, dim } from '../output.js';
import { validateRoundTableId } from '../validate.js';

// ---- Types ------------------------------------------------------------------
Expand Down Expand Up @@ -41,14 +41,6 @@ interface CreateRoundTableResponse extends RoundTable {

// ---- Helpers ----------------------------------------------------------------

// NO_COLOR compliance — mirrors the pattern in output.ts
const NO_COLOR = 'NO_COLOR' in process.env;
function cyan(s: string): string { return NO_COLOR ? s : `\x1b[36m${s}\x1b[0m`; }
function green(s: string): string { return NO_COLOR ? s : `\x1b[32m${s}\x1b[0m`; }
function yellow(s: string): string { return NO_COLOR ? s : `\x1b[33m${s}\x1b[0m`; }
function bold(s: string): string { return NO_COLOR ? s : `\x1b[1m${s}\x1b[0m`; }
function dim(s: string): string { return NO_COLOR ? s : `\x1b[2m${s}\x1b[0m`; }

function sleep(ms: number): Promise<void> {
return new Promise(resolve => setTimeout(resolve, ms));
}
Expand Down
12 changes: 6 additions & 6 deletions cli/src/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// Tests that toggle NO_COLOR after import won't affect this cached value.
const NO_COLOR = 'NO_COLOR' in process.env;

function green(s: string): string { return NO_COLOR ? s : `\x1b[32m${s}\x1b[0m`; }
function yellow(s: string): string { return NO_COLOR ? s : `\x1b[33m${s}\x1b[0m`; }
function red(s: string): string { return NO_COLOR ? s : `\x1b[31m${s}\x1b[0m`; }
function cyan(s: string): string { return NO_COLOR ? s : `\x1b[36m${s}\x1b[0m`; }
function bold(s: string): string { return NO_COLOR ? s : `\x1b[1m${s}\x1b[0m`; }
function dim(s: string): string { return NO_COLOR ? s : `\x1b[2m${s}\x1b[0m`; }
export function green(s: string): string { return NO_COLOR ? s : `\x1b[32m${s}\x1b[0m`; }
export function yellow(s: string): string { return NO_COLOR ? s : `\x1b[33m${s}\x1b[0m`; }
export function red(s: string): string { return NO_COLOR ? s : `\x1b[31m${s}\x1b[0m`; }
export function cyan(s: string): string { return NO_COLOR ? s : `\x1b[36m${s}\x1b[0m`; }
export function bold(s: string): string { return NO_COLOR ? s : `\x1b[1m${s}\x1b[0m`; }
export function dim(s: string): string { return NO_COLOR ? s : `\x1b[2m${s}\x1b[0m`; }

export function isJsonMode(): boolean {
return process.argv.includes('--json') || process.env.ADMP_JSON === '1';
Expand Down
19 changes: 18 additions & 1 deletion cli/src/validate.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test, expect, beforeEach, afterEach } from 'bun:test';
import { validateMessageId, validateGroupId, validateSeedHex } from './validate.js';
import { validateMessageId, validateGroupId, validateSeedHex, validateRoundTableId } from './validate.js';

// All validators call process.exit(1) on failure, so we intercept it.
let exitCalled: number | null;
Expand Down Expand Up @@ -53,6 +53,23 @@ test('validateGroupId: rejects dots', () => {
expect(exitCalled).toBe(1);
});

// --- validateRoundTableId ---

test('validateRoundTableId: accepts valid round table ID', () => {
validateRoundTableId('rt_abc123-def');
expect(exitCalled).toBeNull();
});

test('validateRoundTableId: rejects slashes', () => {
validateRoundTableId('rt/abc');
expect(exitCalled).toBe(1);
});

test('validateRoundTableId: rejects dots', () => {
validateRoundTableId('rt.abc');
expect(exitCalled).toBe(1);
});

// --- validateSeedHex ---

test('validateSeedHex: accepts valid 64-char hex', () => {
Expand Down