Commit 86ba9eec authored by Medicean's avatar Medicean

(Enhance:Module:Terminal) add new local command ashelp & ascmd

parent f98c1fd5
......@@ -14,6 +14,16 @@
* 新增「复制文件名」和「复制文件路径」功能,目标复制文件名或路径到剪贴板
* 编辑文件菜单可选择「标签打开」和「窗口打开」
### 虚拟终端
* 新增两条本地命令
* ashelp 列出所有本地命令
* ascmd 指定某个文件执行后续的命令. eg: ascmd /bin/bash 这样后续输入的命令将会使用 /bin/bash 来执行。注意仅对当前有效, 如果需要持久生效, 需要在shell配置中的「其它配置」设置。
### 系统设置
* 新增「默认设置」, 可在此配置文件管理默认编辑文件打开方式
### Other
* 新增 Python2 Custom CGI shell 示例
......
......@@ -185,7 +185,11 @@ module.exports = {
system: 'System Info',
user: 'Current User',
path: 'Current Path'
}
},
ascmd: {
ashelp: `Usage:\nascmd file\t\tExecute the command with file, eg: ascmd /bin/bash\n`,
ascmd: (cmd) => antSword.noxss(`Will execute the command with ${cmd}.`),
},
},
filemanager: {
title: 'FileManager',
......
......@@ -186,7 +186,11 @@ module.exports = {
system: '系统信息',
user: '当前用户',
path: '当前路径'
}
},
ascmd: {
ashelp: `使用帮助:\nascmd file\t\t指定file来执行命令,eg: ascmd /bin/bash\n`,
ascmd: (cmd) => antSword.noxss(`将使用 ${cmd} 执行命令.`),
},
},
filemanager: {
title: '文件管理',
......
......@@ -39,6 +39,7 @@ class Terminal {
this.term = null;
this.cell = cell;
this.isWin = true;
this.sessbin = null;
this.core = new antSword['core'][opts['type']](opts);
this.cache = new antSword['CacheManager'](this.opts['_id']);
......@@ -95,6 +96,7 @@ class Terminal {
* @return {None} [description]
*/
initTerminal(ret, dom) {
let self = this;
let info = ret.split('\t');
let infoUser, infoPath, infoDrive, infoSystem;
let banner = `[[b;cyan;](*) ${LANG['banner']['title']}]`;
......@@ -136,6 +138,21 @@ class Terminal {
if (cmd === 'exit' || cmd === 'quit') { return this.cell.close() }
// clear清空
if (cmd === 'cls' || cmd === 'clear') { return term.clear() }
if (cmd === 'ashelp'){
term.echo(LANG['ascmd']['ashelp']);
return;
}
if ( cmd.substr(0,5) === 'ascmd') {
var sessbin = cmd.substr(5).trim();
if(sessbin.length>0){
self.sessbin = sessbin;
term.echo(LANG['ascmd']['ascmd'](self.sessbin));
}else{
term.echo(LANG['ascmd']['ashelp']);
}
return;
}
term.pause();
// 是否有缓存
let cacheTag = 'command-' + new Buffer(this.path + cmd).toString('base64');
......@@ -152,6 +169,9 @@ class Terminal {
let _bin = this.isWin ? 'cmd' : '/bin/sh';
let _confBin = (this.opts['otherConf'] || {})['command-path'];
_bin = _confBin || _bin;
if(self.sessbin !== null) {
_bin = self.sessbin;
}
// 开始执行命令
this.core.request(
this.core.command.exec({
......@@ -202,7 +222,9 @@ class Terminal {
exit: false,
// < 1.0.0 时使用3个参数 completion: (term, value, callback) => {}
completion: (value, callback) => {
callback(
callback([
'ashelp', 'ascmd', 'quit', 'exit'
].concat(
this.isWin ? [
'dir', 'whoami', 'net', 'ipconfig', 'netstat', 'cls',
'wscript', 'nslookup', 'copy', 'del', 'ren', 'md', 'type',
......@@ -213,7 +235,7 @@ class Terminal {
'whoami', 'ifconfig', 'clear',
'ping'
]
)
))
},
keydown: (event, terminal) => {
if(event.ctrlKey == true) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment