updates ssh.ts
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
import {parseArgs} from "node:util";
|
||||
|
||||
import {execCommandShell, log, readFileToString, term,} from "https://script.hatter.ink/@29/deno-commons-mod.ts";
|
||||
import {execCommandShell, log, readFileToString, term,} from "https://script.hatter.ink/@32/deno-commons-mod.ts";
|
||||
import JSON5 from "npm:json5";
|
||||
|
||||
class SshTsArgs {
|
||||
@@ -49,7 +49,11 @@ function printSshConfig(sshConfig: SshConfig) {
|
||||
maxProfileHostLength = sshProfile.host.length;
|
||||
}
|
||||
}
|
||||
console.log(term.auto("[green][OK ][/green] Total 10 server(s):"));
|
||||
console.log(
|
||||
term.auto(
|
||||
`[green]\\[OK ][/] Total [bold]${allProfiles.length}[/] server(s):`,
|
||||
),
|
||||
);
|
||||
allProfiles.sort((a, b) => a.localeCompare(b));
|
||||
for (let i = 0; i < allProfiles.length; i++) {
|
||||
const k = allProfiles[i];
|
||||
@@ -57,7 +61,7 @@ function printSshConfig(sshConfig: SshConfig) {
|
||||
const features = [];
|
||||
if (sshProfile.proxy) features.push("proxy");
|
||||
if (sshProfile.forward_agent) features.push("forward_agent");
|
||||
const nameWithPad = `${k}${
|
||||
const nameWithPad = `[bold]${k}[/]${
|
||||
" ".repeat(maxProfileNameLength - k.length)
|
||||
}`;
|
||||
const hostWithPad = `${sshProfile.host}${
|
||||
@@ -69,7 +73,7 @@ function printSshConfig(sshConfig: SshConfig) {
|
||||
: "aliases"
|
||||
}: [${(sshProfile.alias && sshProfile.alias.join(", ")) || ""}]`;
|
||||
console.log(term.auto(
|
||||
`- ${nameWithPad} : [blue]${hostWithPad}[/blue] [yellow]${alias}[/yellow] # ${sshProfile.comment}${
|
||||
`- ${nameWithPad} : [blue][[[${hostWithPad}]]][/] [yellow][[[${alias}]]][/] # ${sshProfile.comment}${
|
||||
(features.length > 0) ? (" ;[" + features.join(" ") + "]") : ""
|
||||
}`,
|
||||
));
|
||||
@@ -80,7 +84,9 @@ function printSshConfig(sshConfig: SshConfig) {
|
||||
if (sshConfig.default_proxy) features.push("proxy");
|
||||
if (sshConfig.default_forward_agent) features.push("forward_agent");
|
||||
console.log();
|
||||
log.info(`Global default features: [${features.join(" ")}]`);
|
||||
log.info(
|
||||
term.auto(`Global default features: [[[[${features.join(" ")}]]]]`),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,20 +200,21 @@ async function main() {
|
||||
sshConfig.default_username || "root";
|
||||
sshArgs.push(`${sshUsername}@${sshProfile.host}`);
|
||||
|
||||
const joinedSshArgs = sshArgs.map((arg) => {
|
||||
if (arg.includes(" ")) {
|
||||
return `"${arg}"`;
|
||||
} else {
|
||||
return arg;
|
||||
}
|
||||
}).join(" ");
|
||||
console.log(
|
||||
term.auto(`[green][OK ][/green] ${sshCommand} ${
|
||||
sshArgs.map((arg) => {
|
||||
if (arg.includes(" ")) {
|
||||
return `"${arg}"`;
|
||||
} else {
|
||||
return arg;
|
||||
}
|
||||
}).join(" ")
|
||||
}`),
|
||||
term.auto(
|
||||
`[green]\\[OK ][/] [bold][blue][[[${sshCommand}]]][/][/] [yellow][[[${joinedSshArgs}]]][/]`,
|
||||
),
|
||||
);
|
||||
await execCommandShell(sshCommand, sshArgs);
|
||||
}
|
||||
await main();
|
||||
|
||||
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260207T015534+08:00.MEYCIQDrK2IaMQnSL1d0Z+jd
|
||||
// G9+7qDQzyNxCR2N18b/+3lHjHQIhAM/Om/+Z6qoK2hiX84idYKeHc/JmizWUi/yqxI+xcvWl
|
||||
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260208T142616+08:00.MEYCIQDb99eHtM0E2g2/SJc2
|
||||
// cLX9TpTZIY6WFl1hR0F9E3RmhwIhAJMoT77cJYjJwvLySwe8QYzGrpWHe4ROBIdRXiQERNMT
|
||||
|
||||
Reference in New Issue
Block a user