diff options
Diffstat (limited to 'qml')
-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) { |