feature(cloudcmd) add --sync-console-path

This commit is contained in:
coderaiser 2018-03-20 17:34:52 +02:00
parent f680180d95
commit 293043999c
10 changed files with 58 additions and 10 deletions

View file

@ -89,6 +89,7 @@ Cloud Commander supports command line parameters:
| `--contact` | enable contact
| `--config-dialog` | enable config dialog
| `--console` | enable console
| `--sync-console-path` | sync console path
| `--terminal` | enable terminal
| `--terminal-path` | set terminal path
| `--vim` | enable vim hot keys
@ -106,6 +107,7 @@ Cloud Commander supports command line parameters:
| `--no-contact` | disable contact
| `--no-config-dialog` | disable config dialog
| `--no-console` | disable console
| `--no-sync-console-path` | do not sync console path
| `--no-terminal` | disable terminal
| `--no-vim` | disable vim hot keys
| `--no-columns` | set visible default columns
@ -376,6 +378,7 @@ Here is description of options:
"contact" : true, /* enable contact */
"configDialog" : true, /* enable config dialog */
"console" : true, /* enable console */
"syncConsolePath" : false /* do not sync console path */
"terminal" : false, /* disable terminal */
"terminalPath" : '', /* path of a terminal */
"vim" : false, /* disable vim hot keys */
@ -393,6 +396,7 @@ Some config options can be overridden with `environment variables` such:
- `CLOUDCMD_CONTACT` - enable contact
- `CLOUDCMD_CONFIG_DIALOG` - enable config dialog
- `CLOUDCMD_CONSOLE` - enable console
- `CLOUDCMD_SYNC_CONSOLE_PATH` - sync console path
- `CLOUDCMD_TERMINAL` - enable terminal
- `CLOUDCMD_TERMINAL_PATH` - set terminal path
- `CLOUDCMD_AUTH` - enable authentication

View file

@ -37,6 +37,11 @@
"value": "true",
"required": false
},
"CLOUDCMD_SYNC_CONSOLE_PATH": {
"description": "sync console path",
"value": "false",
"required": false
},
"CLOUDCMD_TERMINAL": {
"description": "enable terminal",
"value": "true",

View file

@ -41,6 +41,7 @@ const args = require('minimist')(argv.slice(2), {
'progress',
'config-dialog',
'console',
'sync-console-path',
'contact',
'terminal',
'one-panel-mode',
@ -68,6 +69,7 @@ const args = require('minimist')(argv.slice(2), {
contact : choose(env.bool('contact'), config('contact')),
terminal : choose(env.bool('terminal'), config('terminal')),
'sync-console-path': choose(env.bool('sync_console_path'), config('syncConsolePath')),
'config-dialog': choose(env.bool('config_dialog'), config('configDialog')),
'terminal-path': env('terminal_path') || config('terminalPath'),
'one-panel-mode': choose(env.bool('one_panel_mode'), config('onePanelMode')),
@ -114,6 +116,7 @@ function main() {
config('username', args.username);
config('progress', args.progress);
config('console', args.console);
config('syncConsolePath', args['sync-console-path']);
config('contact', args.contact);
config('terminal', args.terminal);
config('terminalPath', args['terminal-path']);

View file

@ -3,13 +3,15 @@
/* global Util, DOM */
const itype = require('itype/legacy');
const emitify = require('emitify/legacy');
const Emitify = require('emitify/legacy');
const inherits = require('inherits');
const rendy = require('rendy');
const exec = require('execon');
const Images = require('./dom/images');
const join = require('join-io/www/join');
const jonny = require('jonny/legacy');
const currify = require('currify/legacy');
const bind = (f, ...a) => () => f(...a);
const {
@ -204,6 +206,7 @@ function CloudCmdProto(Util, DOM) {
CloudCmd.PREFIX_URL = prefix + apiURL;
CloudCmd.config = (key) => config[key];
CloudCmd.config.if = currify((key, fn, a) => config[key] && fn(a));
CloudCmd._config = (key, value) => {
/*
* should be called from config.js only
@ -584,7 +587,7 @@ function CloudCmdProto(Util, DOM) {
const path = Info.dirPath || parentDirPath;
CloudCmd.loadDir({path}, () => {
const panel = Info.panel;
const {panel} = Info;
const current = DOM.getCurrentByName(dir);
const first = DOM.getFiles(panel)[0];

View file

@ -13,18 +13,22 @@ const {
CurrentInfo:Info,
} = DOM;
const rmLastSlash = (a) => a.replace(/\/$/, '') || '/';
CloudCmd.Konsole = ConsoleProto;
function ConsoleProto() {
const noop = () => {};
let konsole;
const {config} = CloudCmd;
if (!CloudCmd.config('console'))
const noop = () => {};
const cd = currify((fn, dir) => fn(`cd ${rmLastSlash(dir)}`));
if (!config('console'))
return {
show: noop
};
const config = CloudCmd.config;
const Name = 'Konsole';
const TITLE = 'Console';
@ -54,7 +58,7 @@ function ConsoleProto() {
};
this.clear = () => {
Console.clear();
konsole.clear();
};
function getPrefix() {
@ -72,20 +76,38 @@ function ConsoleProto() {
};
}
function onPath(path) {
if (Info.dirPath === path)
return;
CloudCmd.loadDir({
path,
});
}
const getDirPath = () => {
if (config('syncConsolePath'))
return Info.dirPath;
};
function create(callback) {
const options = {
cwd: getDirPath(),
env: getEnv(),
prefix: getPrefix(),
socketPath: CloudCmd.PREFIX,
};
Console(Element, options, (spawn) => {
konsole = Console(Element, options, (spawn) => {
spawn.on('connect', exec.with(authCheck, spawn));
spawn.on('path', config.if('syncConsolePath', onPath));
CloudCmd.on('active-dir', config.if('syncConsolePath', cd(spawn.handler)));
exec(callback);
});
Console.addShortCuts({
konsole.addShortCuts({
'P': () => {
const command = Console.getPromptText();
const path = DOM.getCurrentDirPath();
@ -112,7 +134,7 @@ function ConsoleProto() {
CloudCmd.View.show(Element, {
afterShow: () => {
Console.focus();
konsole.focus();
exec(callback);
}
});

Binary file not shown.

Before

Width:  |  Height:  |  Size: 158 KiB

After

Width:  |  Height:  |  Size: 220 KiB

Before After
Before After

View file

@ -27,6 +27,7 @@
"configDialog": true,
"onePanelMode": false,
"console": true,
"syncConsolePath": false,
"terminal": false,
"terminalPath": "",
"showConfig": false,

View file

@ -22,6 +22,7 @@
"--one-panel-mode ": "set one panel mode",
"--config-dialog ": "enable config dialog",
"--console ": "enable console",
"--sync-console-path ": "sync console path",
"--contact ": "enable contact",
"--terminal ": "enable terminal",
"--terminal-path ": "set terminal path",
@ -39,6 +40,7 @@
"--no-html-dialogs ": "do not use html dialogs",
"--no-config-dialog ": "disable config dialog",
"--no-console ": "disable console",
"--no-sync-console-path ": "do not sync console path",
"--no-contact ": "disable contact",
"--no-terminal ": "disable terminal",
"--no-vim ": "disable vim hot keys",

View file

@ -46,6 +46,7 @@ programs in browser from any computer, mobile or tablet device.
--contact enable contact
--config-dialog enable config dialog
--console enable console
--sync-console-path sync console path
--terminal enable terminal
--terminal-path set terminal path
--vim enable vim hot keys
@ -63,6 +64,7 @@ programs in browser from any computer, mobile or tablet device.
--no-contact disable contact
--no-config-dialog disable config dialog
--no-console disable console
--no-sync-console-path do not sync console path
--no-terminal disable terminal
--no-vim disable vim hot keys
--no-columns set visible default columns

View file

@ -168,4 +168,10 @@
One Panel Mode
</label>
</li>
<li>
<label>
<input data-name="js-syncConsolePath" type="checkbox" {{ syncConsolePath }}>
Sync Console Path
</label>
</li>
</ul>