mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature: client: add Command Line
This commit is contained in:
parent
a5229fae06
commit
24fbeec62d
7 changed files with 48 additions and 2 deletions
|
|
@ -499,6 +499,11 @@ async function switchKey(event) {
|
|||
|
||||
break;
|
||||
|
||||
case KEY.COLON:
|
||||
CloudCmd.CommandLine.show();
|
||||
event.preventDefault();
|
||||
break;
|
||||
|
||||
/* чистим хранилище */
|
||||
case KEY.D:
|
||||
if (ctrlMeta) {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
38
client/modules/command-line.js
Normal file
38
client/modules/command-line.js
Normal 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() {
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue