summaryrefslogtreecommitdiff
path: root/asciifarm/client
diff options
context:
space:
mode:
authortroido <troido@protonmail.com>2019-01-18 17:59:45 +0100
committertroido <troido@protonmail.com>2019-01-18 17:59:45 +0100
commit01399d4be6f3dacb7c0bed2b84edbbc63331b83e (patch)
treeb0293a505158c6a537ee75320469cc335de07b89 /asciifarm/client
parentb4cb3cf82337c5a0d560fd77c9a921298b07aa21 (diff)
config templates are now actually used
Diffstat (limited to 'asciifarm/client')
-rw-r--r--asciifarm/client/commandhandler.py19
-rw-r--r--asciifarm/client/inputhandler.py5
-rw-r--r--asciifarm/client/loaders.py4
3 files changed, 15 insertions, 13 deletions
diff --git a/asciifarm/client/commandhandler.py b/asciifarm/client/commandhandler.py
index db9f625..ca72b68 100644
--- a/asciifarm/client/commandhandler.py
+++ b/asciifarm/client/commandhandler.py
@@ -51,17 +51,16 @@ class CommandHandler:
}
def execute(self, action):
- try:
- if isinstance(action[0], str):
- command = action[0]
- if command in self.commands:
- self.commands[command](*action[1:])
- else:
- raise InvalidCommandException("Invalid command '{}'".format(command))
+ if action is None:
+ return
+ if isinstance(action[0], str):
+ command = action[0]
+ if command in self.commands:
+ self.commands[command](*action[1:])
else:
- raise Exception("Command should be a string")
- except Exception as e:
- self.log(e)
+ raise InvalidCommandException("Invalid command '{}'".format(command))
+ else:
+ raise Exception("Command should be a string")
# Commands
diff --git a/asciifarm/client/inputhandler.py b/asciifarm/client/inputhandler.py
index 8d99c40..850e890 100644
--- a/asciifarm/client/inputhandler.py
+++ b/asciifarm/client/inputhandler.py
@@ -35,7 +35,10 @@ class InputHandler:
else:
try:
command, _sep, arg = message[1:].partition(' ')
- self.commandHandler.execute([command, arg])
+ try:
+ self.commandHandler.execute([command, arg])
+ except Exception as e:
+ self.log(e)
except InvalidCommandException as e:
self.client.log(", ".join(e.args))
else:
diff --git a/asciifarm/client/loaders.py b/asciifarm/client/loaders.py
index 0b4c5b7..8330e0e 100644
--- a/asciifarm/client/loaders.py
+++ b/asciifarm/client/loaders.py
@@ -23,7 +23,7 @@ def loadKeybindings(name):
for ftemplate in data.get("templates", []):
if ftemplate.partition(os.sep)[0] in {".", ".."}:
ftemplate = os.path.relpath(ftemplate, fname)
- template = loadKeyBindings(ftemplate)
+ template = loadKeybindings(ftemplate)
bindings.update(template.get("actions", {}))
help = template.get("help", help)
bindings.update(data.get("actions", {}))
@@ -31,7 +31,7 @@ def loadKeybindings(name):
return {"actions": bindings, "help": help}
-standardCharFiles = {name, os.path.join(charmapPath, file) for name, file in {
+standardCharFiles = {name: os.path.join(charmapPath, file) for name, file in {
"default": "default.json",
"fullwith": "fullwidth.json",
"fw": "fullwidth.json",