Skip to content

Commit 38e7e7b

Browse files
committed
add colors to output
1 parent 9b1fe69 commit 38e7e7b

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

sandbox.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { Command } from "@cliffy/command";
22
import { Sandbox } from "@deno/sandbox";
3+
import { green, magenta, red } from "@std/fmt/colors";
34

45
import { getAppFromConfig, readConfig } from "./config.ts";
56
import { renderTemporalTimestamp, withApp } from "./util.ts";
67
import { createTrpcClient } from "./auth.ts";
78
import type { GlobalOptions } from "./main.ts";
8-
import { get } from "node:http";
99

1010
type SandboxContext = GlobalOptions & {
1111
org?: string;
@@ -68,11 +68,13 @@ export const sandboxListCommand = new Command<SandboxContext>()
6868
].join(" "));
6969

7070
for (const sandbox of processed) {
71+
const isRunning = sandbox.status === "running";
72+
const status = sandbox.status.padEnd(statusHeaderLength);
7173
console.log(
7274
[
7375
sandbox.id.padEnd(idHeaderLength),
7476
sandbox.createdAt.padEnd(createdAtHeaderLength),
75-
sandbox.status.padEnd(statusHeaderLength),
77+
isRunning ? green(status) : red(status),
7678
sandbox.duration.padEnd(uptimeHeaderLength),
7779
].join(" "),
7880
);
@@ -141,6 +143,7 @@ export const sandboxSshCommand = new Command<SandboxContext>()
141143

142144
if (which.success) {
143145
// If ssh is available, directly spawn ssh process
146+
console.log(`ssh ${connectInfo}`);
144147
const command = new Deno.Command("ssh", {
145148
args: [connectInfo],
146149
stdin: "inherit",
@@ -150,8 +153,12 @@ export const sandboxSshCommand = new Command<SandboxContext>()
150153

151154
const _sshProcess = command.spawn();
152155
} else {
156+
// Fallback: just print the connection info
153157
console.log(
154-
`Started ssh session, you can now connect to ${connectInfo}.\nUse Ctrl+C to exit.`,
158+
`Started ssh session. You can now connect to ${magenta(connectInfo)}
159+
160+
Example:
161+
ssh ${connectInfo}`,
155162
);
156163
}
157164
});

0 commit comments

Comments
 (0)