allow specification of username on the commandline

pull/4/head
Blake DeMarcy 2017-05-05 10:20:11 -05:00
parent 5cfac74c95
commit bbe7dc0d41
1 changed files with 11 additions and 17 deletions

View File

@ -35,24 +35,18 @@ import os
import re import re
# XxX_N0_4rgP4rs3_XxX ###yoloswag # XxX_N0_4rgP4rs3_XxX ###yoloswag
try: def get_arg(key, default=None, get_value=True):
port_spec = argv.index("--port") try:
port = argv[port_spec+1] spec = argv.index("--" + key)
except ValueError: # --port not specified value = argv[spec + 1] if get_value else True
port = 7099 except ValueError: # --key not specified
except IndexError: # flag given but no value value = default
exit("thats not how this works, silly! --port 7099") except IndexError: # flag given but no value
exit("invalid format for --" + key)
return value
try: try:
host_spec = argv.index("--host") network = BBJ(get_arg("host", "127.0.0.1"), get_arg("port", 7099))
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")
try:
network = BBJ(host, port)
except URLError as e: except URLError as e:
# print the connection error in red # print the connection error in red
exit("\033[0;31m%s\033[0m" % repr(e)) 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 chain. The user is run through this before starting the
curses app. 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 == "": if name == "":
motherfucking_rainbows("~~W3 4R3 4n0nYm0u5~~") motherfucking_rainbows("~~W3 4R3 4n0nYm0u5~~")
else: else: