diff --git a/src/subcommands/ps.ts b/src/subcommands/ps.ts index a992401..79c1e84 100644 --- a/src/subcommands/ps.ts +++ b/src/subcommands/ps.ts @@ -39,9 +39,12 @@ const createTable = () => "BRIDGE", "PORTS", "CREATED", - ]), + ]) ); +const ellipsis = (str: string, maxLength: number) => + str.length > maxLength ? `${str.slice(0, maxLength - 3)}...` : str; + const populateTable = (table: Table, vms: VirtualMachine[]) => Effect.sync(() => { for (const vm of vms) { @@ -51,7 +54,7 @@ const populateTable = (table: Table, vms: VirtualMachine[]) => vm.memory, formatStatus(vm), vm.pid?.toString() ?? "-", - basename(vm.drivePath || vm.isoPath || "-"), + ellipsis(basename(vm.drivePath || vm.isoPath || "-"), 20), vm.bridge ?? "-", formatPorts(vm.portForward), dayjs.utc(vm.createdAt).local().fromNow(), @@ -76,7 +79,7 @@ const psEffect = (all: boolean) => Effect.all([fetchVMs(all), createTable()]), Effect.flatMap(([vms, table]) => populateTable(table, vms)), Effect.flatMap(displayTable), - Effect.catchAll(handleError), + Effect.catchAll(handleError) ); export default async function (all: boolean) { @@ -86,13 +89,11 @@ export default async function (all: boolean) { function formatStatus(vm: VirtualMachine) { switch (vm.status) { case "RUNNING": - return `Up ${ - dayjs - .utc(vm.updatedAt) - .local() - .fromNow() - .replace("ago", "") - }`; + return `Up ${dayjs + .utc(vm.updatedAt) + .local() + .fromNow() + .replace("ago", "")}`; case "STOPPED": return `Exited ${dayjs.utc(vm.updatedAt).local().fromNow()}`; default: -- 2.51.2 From 6f797ba02e5a0d71a7120b6475efa5ab218c5546 Mon Sep 17 00:00:00 2001 From: Tsiry Sandratraina Date: Sat, 22 Nov 2025 15:33:33 +0300 Subject: [PATCH 2/2] run format --- src/subcommands/ps.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/subcommands/ps.ts b/src/subcommands/ps.ts index 79c1e84..f392059 100644 --- a/src/subcommands/ps.ts +++ b/src/subcommands/ps.ts @@ -39,7 +39,7 @@ const createTable = () => "BRIDGE", "PORTS", "CREATED", - ]) + ]), ); const ellipsis = (str: string, maxLength: number) => @@ -79,7 +79,7 @@ const psEffect = (all: boolean) => Effect.all([fetchVMs(all), createTable()]), Effect.flatMap(([vms, table]) => populateTable(table, vms)), Effect.flatMap(displayTable), - Effect.catchAll(handleError) + Effect.catchAll(handleError), ); export default async function (all: boolean) { @@ -89,11 +89,13 @@ export default async function (all: boolean) { function formatStatus(vm: VirtualMachine) { switch (vm.status) { case "RUNNING": - return `Up ${dayjs - .utc(vm.updatedAt) - .local() - .fromNow() - .replace("ago", "")}`; + return `Up ${ + dayjs + .utc(vm.updatedAt) + .local() + .fromNow() + .replace("ago", "") + }`; case "STOPPED": return `Exited ${dayjs.utc(vm.updatedAt).local().fromNow()}`; default: