diff --git a/src/cli/client.ts b/src/cli/client.ts index dab5ef3..db1e30a 100644 --- a/src/cli/client.ts +++ b/src/cli/client.ts @@ -88,8 +88,7 @@ function parseArgv(argv: string[]): { // Allow `nc list groups` as well as `nc list-groups`. Server rejects // unknowns, so the naive join is safe — at worst the user gets an // unknown-command error. - const command = - positional.length >= 2 ? `${positional[0]}-${positional[1]}` : positional[0]; + const command = positional.length >= 2 ? `${positional[0]}-${positional[1]}` : positional[0]; return { command, args, json }; } @@ -124,8 +123,6 @@ function formatTransportError(e: unknown): string { } main().catch((err) => { - process.stderr.write( - `nc: unexpected error: ${err instanceof Error ? err.message : String(err)}\n`, - ); + process.stderr.write(`nc: unexpected error: ${err instanceof Error ? err.message : String(err)}\n`); process.exit(2); }); diff --git a/src/cli/dispatch.ts b/src/cli/dispatch.ts index 62c001b..6593750 100644 --- a/src/cli/dispatch.ts +++ b/src/cli/dispatch.ts @@ -9,10 +9,7 @@ import type { CallerContext, ErrorCode, RequestFrame, ResponseFrame } from './frame.js'; import { lookup } from './registry.js'; -export async function dispatch( - req: RequestFrame, - ctx: CallerContext, -): Promise { +export async function dispatch(req: RequestFrame, ctx: CallerContext): Promise { const cmd = lookup(req.command); if (!cmd) { return err(req.id, 'unknown-command', `no command "${req.command}"`); diff --git a/src/cli/format.ts b/src/cli/format.ts index c468143..5ce67c0 100644 --- a/src/cli/format.ts +++ b/src/cli/format.ts @@ -41,11 +41,8 @@ function isFlatRecord(x: unknown): x is Record { function renderTable(rows: Record[]): string { if (rows.length === 0) return '(no rows)'; const cols = Object.keys(rows[0]); - const widths = cols.map((c) => - Math.max(c.length, ...rows.map((r) => String(r[c] ?? '').length)), - ); - const fmtRow = (vals: string[]): string => - vals.map((v, i) => v.padEnd(widths[i])).join(' '); + const widths = cols.map((c) => Math.max(c.length, ...rows.map((r) => String(r[c] ?? '').length))); + const fmtRow = (vals: string[]): string => vals.map((v, i) => v.padEnd(widths[i])).join(' '); const lines = [ fmtRow(cols), fmtRow(widths.map((w) => '─'.repeat(w))), diff --git a/src/cli/socket-client.ts b/src/cli/socket-client.ts index 1931cb0..c94a4dc 100644 --- a/src/cli/socket-client.ts +++ b/src/cli/socket-client.ts @@ -23,10 +23,7 @@ export class SocketTransport implements Transport { let buffer = ''; let settled = false; - const settle = ( - action: 'resolve' | 'reject', - valueOrErr: ResponseFrame | Error, - ): void => { + const settle = (action: 'resolve' | 'reject', valueOrErr: ResponseFrame | Error): void => { if (settled) return; settled = true; try { @@ -51,12 +48,7 @@ export class SocketTransport implements Transport { const frame = JSON.parse(line) as ResponseFrame; settle('resolve', frame); } catch (e) { - settle( - 'reject', - new Error( - `malformed response from host: ${e instanceof Error ? e.message : String(e)}`, - ), - ); + settle('reject', new Error(`malformed response from host: ${e instanceof Error ? e.message : String(e)}`)); } }); diff --git a/src/cli/socket-server.ts b/src/cli/socket-server.ts index d77ce25..7ed2683 100644 --- a/src/cli/socket-server.ts +++ b/src/cli/socket-server.ts @@ -107,10 +107,5 @@ function write(conn: net.Socket, frame: ResponseFrame): void { function isRequestFrame(x: unknown): x is RequestFrame { if (!x || typeof x !== 'object') return false; const o = x as Record; - return ( - typeof o.id === 'string' && - typeof o.command === 'string' && - typeof o.args === 'object' && - o.args !== null - ); + return typeof o.id === 'string' && typeof o.command === 'string' && typeof o.args === 'object' && o.args !== null; }