chrome-cmd
Version:
Control Chrome from the command line - List tabs, execute JavaScript, and more
40 lines (39 loc) • 1.44 kB
JavaScript
import { Command } from "commander";
import { logger } from "../../../shared/utils/helpers/logger.js";
import { PathHelper } from "../../../shared/utils/helpers/path.helper.js";
import { detectShell } from "../../../shared/utils/helpers/shell-utils.js";
import { CommandNames, SubCommandNames } from "../../schemas/definitions.js";
import { createSubCommandFromSchema } from "../../schemas/utils.js";
import { uninstallBashCompletion, uninstallZshCompletion } from "./utils.js";
function createCompletionUninstallCommand() {
return createSubCommandFromSchema(CommandNames.COMPLETION, SubCommandNames.COMPLETION_UNINSTALL, async () => {
if (PathHelper.isWindows()) {
logger.newline();
logger.warning("\u26A0\uFE0F Shell completion is not supported on Windows");
logger.newline();
process.exit(1);
}
const shell = detectShell();
try {
switch (shell) {
case "zsh":
await uninstallZshCompletion();
break;
case "bash":
await uninstallBashCompletion();
break;
default:
logger.error(`\u274C Unsupported shell: ${shell}`);
logger.newline();
logger.info("\u{1F41A} Supported shells: zsh, bash");
process.exit(1);
}
} catch (error) {
logger.error(`Failed to uninstall completion: ${error}`);
process.exit(1);
}
});
}
export {
createCompletionUninstallCommand
};