UNPKG

@eightshone/sshman

Version:
78 lines 3.06 kB
#!/usr/bin/env node var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; import { Command } from "commander"; import init from "./core/functions/init.js"; import { VERSION } from "./utils/consts.js"; import interactive from "./core/ui/interactive.js"; import goodbye from "./utils/goodbye.js"; import connectCommand from "./core/commands/connect.js"; import logs from "./core/commands/logs.js"; import exportServers from "./core/commands/exportServers.js"; import isSameVersion from "./core/functions/isSameVersion.js"; import showUpdateMessage from "./core/functions/showUpdateMessage.js"; const program = new Command(); program .name("sshman") .description("A simple terminmal based SSH manager created in Node.js") .version(VERSION, "-v, --version", "output the version number"); program.action(app); program .command("connect") .argument("<string>", "credentials in the format of username[:password]@server[:port]") .option("-s, --save [name]") .description("connect to a new session") .action(connectCommand); program .command("logs") .option("-i, --interactive") .option("-s, --search <terms>") .description("print logs") .action(logs); program .command("export") .argument("[servers...]", "server names separated by spaces") .option("-a, --all", "export all server configurations (ignores any input server names)") .option("-n, --name <file name>", "custom name for output file") .option("-f, --force", "replace existing file") .description("exports server configurations") .action(exportServers); program .command("goodbye") .description("says goodbye") .action(() => { goodbye(); process.exit(); }); program .command("check-updates") .description("check for updates") .action(() => __awaiter(void 0, void 0, void 0, function* () { const [isUptodate, manager] = yield isSameVersion(); showUpdateMessage(isUptodate, manager); })); program.parse(); function app() { return __awaiter(this, void 0, void 0, function* () { // intialize the cli app const { config, logs } = yield init(); yield interactive(config, logs, program); }); } process.on("uncaughtException", (error) => { if (error instanceof Error && error.name === "ExitPromptError") { goodbye(); } else { // Rethrow unknown errors throw error; } }); //# sourceMappingURL=app.js.map