aboutsummaryrefslogtreecommitdiff
path: root/src/command
diff options
context:
space:
mode:
authorAdrian Kummerlaender2015-08-19 21:19:01 +0200
committerAdrian Kummerlaender2015-08-19 21:19:01 +0200
commit75891e7c90ff8ec3533a6a1e9aac66501693d561 (patch)
treebf366a816618fd045f3a67468a0d133e63074b9f /src/command
parente1c314b081fce85c80d1df8788f84cc173ff0e14 (diff)
downloadMetaTerm-75891e7c90ff8ec3533a6a1e9aac66501693d561.tar
MetaTerm-75891e7c90ff8ec3533a6a1e9aac66501693d561.tar.gz
MetaTerm-75891e7c90ff8ec3533a6a1e9aac66501693d561.tar.bz2
MetaTerm-75891e7c90ff8ec3533a6a1e9aac66501693d561.tar.lz
MetaTerm-75891e7c90ff8ec3533a6a1e9aac66501693d561.tar.xz
MetaTerm-75891e7c90ff8ec3533a6a1e9aac66501693d561.tar.zst
MetaTerm-75891e7c90ff8ec3533a6a1e9aac66501693d561.zip
Improve handling of non-existing properties in `set`
Diffstat (limited to 'src/command')
-rw-r--r--src/command/commands.js21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/command/commands.js b/src/command/commands.js
index d5b9787..fce509a 100644
--- a/src/command/commands.js
+++ b/src/command/commands.js
@@ -14,13 +14,17 @@ function execute(output, command) {
notImplemented(args[0]);
}
} catch (exception) {
- notImplemented(args[0]);
+ if ( exception instanceof ReferenceError ) {
+ notImplemented(args[0]);
+ } else {
+ output.error(exception);
+ }
}
}
-function safeEval(output, code) {
+function exec(output, args) {
try {
- var result = eval(code);
+ var result = eval(args.join(' '));
if ( typeof result !== 'undefined' ) {
output.log(result);
@@ -30,10 +34,6 @@ function safeEval(output, code) {
}
}
-function exec(output, args) {
- safeEval(output, args.join(' '));
-}
-
function jump(output, index) {
terminalList.selectItem(index);
}
@@ -61,14 +61,11 @@ function ls(output) {
function set(output, args) {
switch ( args.length ) {
case 2: {
- safeEval(output, 'settings.' + args[0] + '.' + args[1]);
+ output.log(settings.read(args[0], args[1]));
break;
}
case 3: {
- safeEval(
- output,
- 'settings.' + args[0] + '.' + args[1] + ' = "' + args[2] + '"'
- );
+ settings.getSetter(args[0], args[1])(args[2]);
break;
}
default: {