summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortroido <troido@hotmail.com>2017-11-01 12:41:38 +0100
committertroido <troido@hotmail.com>2017-11-01 12:41:38 +0100
commit1febf9663915304f9036acb23c0b6fe379c0f955 (patch)
tree524ce558e1c9386b98cead79e638ac84531d39e3
parentbcc306d36d639b0282c13ba25d187a22fb5e1d9f (diff)
messages can now be logged to a file
-rwxr-xr-xasciifarm/client/main.py3
-rw-r--r--asciifarm/client/start.py6
2 files changed, 5 insertions, 4 deletions
diff --git a/asciifarm/client/main.py b/asciifarm/client/main.py
index baaf8d4..365c647 100755
--- a/asciifarm/client/main.py
+++ b/asciifarm/client/main.py
@@ -37,6 +37,7 @@ def main(argv=None):
parser.add_argument("-s", "--socket", help="the socket type. 'unix' is unix domain sockets, 'abstract' is abstract unix domain sockets and 'inet' is inet sockets. ", choices=["abstract", "unix", "inet"], default="abstract")
parser.add_argument('-k', '--keybindings', help='The file with the keybindings. If it is either of these names: {} it will be loaded from the keybindings directory.'.format(standardKeyFiles), default="default")
parser.add_argument('-c', '--characters', help='The file with the character mappings for the graphics. If it is either of these names: {} it will be loaded from the charmaps directory.'.format(standardCharFiles), default="default")
+ parser.add_argument('-o', '--logfile', help='All game messages will be written to this file.'.format(standardCharFiles), default=None)
colourGroup = parser.add_mutually_exclusive_group()
colourGroup.add_argument('-l', '--colours', '--colors', help='enable colours! :)', action="store_true")
@@ -69,5 +70,5 @@ def main(argv=None):
elif args.nocolours:
colours = False
- clientmain(args.name, args.socket, address, keybindings, charMap, colours)
+ clientmain(args.name, args.socket, address, keybindings, charMap, colours, args.logfile)
diff --git a/asciifarm/client/start.py b/asciifarm/client/start.py
index 4084f7f..e9d3ce7 100644
--- a/asciifarm/client/start.py
+++ b/asciifarm/client/start.py
@@ -14,7 +14,7 @@ defaultAdresses = {
"inet": "localhost:9021",
}
-def main(name, socketType, address, keybindings, characters, colours=False):
+def main(name, socketType, address, keybindings, characters, colours=False, logfile=None):
connection = Connection(socketType)
try:
@@ -27,13 +27,13 @@ def main(name, socketType, address, keybindings, characters, colours=False):
def start(stdscr):
display = Display(stdscr, characters, colours)
- client = Client(stdscr, display, name, connection, keybindings)
+ client = Client(stdscr, display, name, connection, keybindings, logfile)
nonlocal caught_ctrl_c
try:
client.start()
except KeyboardInterrupt:
- caught_ctrl_c = True
client.keepAlive = False
+ caught_ctrl_c = True
curses.wrapper(start)