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

@ -93,6 +93,7 @@ module.exports = {
[modules + '/cloud']: `${dirModules}/cloud.js`,
[modules + '/user-menu']: `${dirModules}/user-menu/index.js`,
[modules + '/polyfill']: `${dirModules}/polyfill.js`,
[modules + '/command-line']: `${dirModules}/command-line.js`,
},
output: {
filename: '[name].js',

View file

@ -172,6 +172,7 @@ Then, start the server again with `cloudcmd` and reload the page.
| `*` | select/unselect all
| `+` | expand selection
| `-` | shrink selection
| `:` | open Command Line
| `Ctrl + X` | cut to buffer
| `Ctrl + C` | copy to buffer
| `Ctrl + V` | paste from buffer

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() {
}

View file

@ -11,6 +11,7 @@
"markdown",
"config",
"contact",
"command-line",
"upload",
"operation",
"konsole",

View file

@ -2,6 +2,7 @@
"name": "cloudcmd",
"version": "16.4.1",
"type": "commonjs",
"commitType": "colon",
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
"description": "File manager for the web with console and editor",
"homepage": "http://cloudcmd.io",