aboutsummaryrefslogtreecommitdiffstats
path: root/clients
diff options
context:
space:
mode:
authorBlake DeMarcy <ofunknowndescent@gmail.com>2017-05-05 10:20:11 -0500
committerBlake DeMarcy <ofunknowndescent@gmail.com>2017-05-05 10:20:11 -0500
commitbbe7dc0d41ed0ce6efe7b91e39660247e95e6231 (patch)
tree640f22d79cce56033e3b517c379b47651f3c7b58 /clients
parent5cfac74c959f1871c529f89fb1d044665b69704d (diff)
downloadbbj-bbe7dc0d41ed0ce6efe7b91e39660247e95e6231.tar.gz
allow specification of username on the commandline
Diffstat (limited to 'clients')
-rw-r--r--clients/urwid/main.py28
1 files changed, 11 insertions, 17 deletions
diff --git a/clients/urwid/main.py b/clients/urwid/main.py
index e960180..f38220c 100644
--- a/clients/urwid/main.py
+++ b/clients/urwid/main.py
@@ -35,24 +35,18 @@ import os
import re
# XxX_N0_4rgP4rs3_XxX ###yoloswag
-try:
- port_spec = argv.index("--port")
- port = argv[port_spec+1]
-except ValueError: # --port not specified
- port = 7099
-except IndexError: # flag given but no value
- exit("thats not how this works, silly! --port 7099")
-
-try:
- host_spec = argv.index("--host")
- host = argv[host_spec+1]
-except ValueError: # --host not specified
- host = "127.0.0.1"
-except IndexError: # flag given but no value
- exit("thats not how this works, silly! --host 127.0.0.1")
+def get_arg(key, default=None, get_value=True):
+ try:
+ spec = argv.index("--" + key)
+ value = argv[spec + 1] if get_value else True
+ except ValueError: # --key not specified
+ value = default
+ except IndexError: # flag given but no value
+ exit("invalid format for --" + key)
+ return value
try:
- network = BBJ(host, port)
+ network = BBJ(get_arg("host", "127.0.0.1"), get_arg("port", 7099))
except URLError as e:
# print the connection error in red
exit("\033[0;31m%s\033[0m" % repr(e))
@@ -1947,7 +1941,7 @@ def log_in():
chain. The user is run through this before starting the
curses app.
"""
- name = sane_value("user_name", "Username", return_empty=True)
+ name = get_arg("user") or sane_value("user_name", "Username", return_empty=True)
if name == "":
motherfucking_rainbows("~~W3 4R3 4n0nYm0u5~~")
else:
Un proyecto texto-plano.xyz