31 lines
738 B
TypeScript
31 lines
738 B
TypeScript
import { defineCommand } from "citty";
|
|
import { listDeployments } from "../lib/shared";
|
|
import { toTable } from "../lib/format";
|
|
|
|
export const ps = defineCommand({
|
|
meta: {
|
|
name: "ps",
|
|
description: "List deployments",
|
|
},
|
|
args: {
|
|
all: {
|
|
type: "boolean",
|
|
alias: "a",
|
|
description:
|
|
"Show all stopped deployments (including those created by the run command)",
|
|
},
|
|
},
|
|
async run({ args: { all } }) {
|
|
console.log(
|
|
toTable(
|
|
(await listDeployments())
|
|
.filter((d) => all || d.status?.replicas)
|
|
.map((d) => ({
|
|
name: d.metadata?.name,
|
|
status: `${d.status?.availableReplicas}/${d.status?.replicas}`,
|
|
})),
|
|
),
|
|
);
|
|
},
|
|
});
|