feature: client: add Command Line

This commit is contained in:
coderaiser 2022-08-06 18:04:37 +03:00
parent a5229fae06
commit 24fbeec62d
7 changed files with 48 additions and 2 deletions

View file

@ -499,6 +499,11 @@ async function switchKey(event) {
break;
case KEY.COLON:
CloudCmd.CommandLine.show();
event.preventDefault();
break;
/* чистим хранилище */
case KEY.D:
if (ctrlMeta) {

View file

@ -25,8 +25,6 @@ module.exports = {
SEMICOLON : 52,
COLON : 54,
A : 65,
C : 67,
@ -70,6 +68,7 @@ module.exports = {
F9 : 120,
F10 : 121,
COLON : 186,
EQUAL : 187,
HYPHEN : 189,
DOT : 190,

View file

@ -0,0 +1,38 @@
'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() {
}