diff options
author | Adrian Kummerlaender | 2015-08-10 21:15:15 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2015-08-10 21:15:15 +0200 |
commit | f38010b397ee60f4cf3bb1c7316eb467d3dc6108 (patch) | |
tree | 95d29fd08b45b32d512cab36b201b5caf646f516 | |
parent | a426875daba0cb923435be835f0100fe13a6255a (diff) | |
download | MetaTerm-f38010b397ee60f4cf3bb1c7316eb467d3dc6108.tar MetaTerm-f38010b397ee60f4cf3bb1c7316eb467d3dc6108.tar.gz MetaTerm-f38010b397ee60f4cf3bb1c7316eb467d3dc6108.tar.bz2 MetaTerm-f38010b397ee60f4cf3bb1c7316eb467d3dc6108.tar.lz MetaTerm-f38010b397ee60f4cf3bb1c7316eb467d3dc6108.tar.xz MetaTerm-f38010b397ee60f4cf3bb1c7316eb467d3dc6108.tar.zst MetaTerm-f38010b397ee60f4cf3bb1c7316eb467d3dc6108.zip |
Implement proper handling of unimplemented commands
-rw-r--r-- | qml/CommandInput.qml | 2 | ||||
-rw-r--r-- | qml/commands.js | 18 |
2 files changed, 16 insertions, 4 deletions
diff --git a/qml/CommandInput.qml b/qml/CommandInput.qml index 5010891..ae48a7a 100644 --- a/qml/CommandInput.qml +++ b/qml/CommandInput.qml @@ -61,7 +61,7 @@ Item { break; } default: { - console.log('"' + prefix + '"' + " is not a command prefix"); + console.log('"' + prefix + '"' + " is not a command prefix."); } } diff --git a/qml/commands.js b/qml/commands.js index 9b4d8de..7d4bdcf 100644 --- a/qml/commands.js +++ b/qml/commands.js @@ -1,9 +1,21 @@ function execute(command) { + var msg = function(name) { + console.log('"' + name + '"' + " is not implemented."); + }; var args = command.split(' '); - var func = args[0]; - args.shift(); - eval(func + '(' + JSON.stringify(args) + ')'); + try { + var closure = eval(args[0]); + + if ( typeof closure === "function" ) { + args.shift(); + closure(args); + } else { + msg(args[0]); + } + } catch (exception) { + msg(args[0]); + } } function exec(args) { |