cloudcmd/client/modules/command-line.js
2022-08-06 18:05:14 +03:00

38 lines
907 B
JavaScript

'use strict';
/* global CloudCmd */
CloudCmd.CommandLine = exports;
const Images = require('../dom/images');
const Dialog = require('../dom/dialog');
module.exports.init = () => {};
module.exports.show = show;
module.exports.hide = hide;
async function show() {
const [, cmd] = await Dialog.prompt('Command Line', '');
const TERMINAL = '^(t|terminal)';
if (RegExp(`${TERMINAL}$`).test(cmd)) {
return await CloudCmd.Terminal.show();
}
if (RegExp(TERMINAL).test(cmd)) {
const command = cmd.replace(RegExp(`${TERMINAL} `), '');
const exitCode = await CloudCmd.TerminalRun.show({
command: `bash -c '${command}'`,
});
if (exitCode === -1)
await Dialog.alert(`☝️ Looks like Terminal is disabled, start Cloud Coammnder with '--terminal' flag.`);
return;
}
}
function hide() {
}