fix a few color-printing bugs & add .gitignore
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
__pycache__
|
||||||
|
*.pyz
|
||||||
|
|
||||||
+3
-1
@@ -7,6 +7,8 @@ from utils import parse_args, safe_input, load_script
|
|||||||
# terminal color codes
|
# terminal color codes
|
||||||
# the readline module requires \001 and \002 because it counts characters
|
# the readline module requires \001 and \002 because it counts characters
|
||||||
# when displaying, but those color codes are zero-width
|
# when displaying, but those color codes are zero-width
|
||||||
|
# also, the libedit library that readline sometimes interfaces with truncates trailing color codes
|
||||||
|
# always end input() prompt strings with a visible character (including a space)
|
||||||
RST = '\001\x1b[0m\002'
|
RST = '\001\x1b[0m\002'
|
||||||
GRN = '\001\x1b[0;32m\002'
|
GRN = '\001\x1b[0;32m\002'
|
||||||
BLU = '\001\x1b[0;34m\002'
|
BLU = '\001\x1b[0;34m\002'
|
||||||
@@ -60,7 +62,7 @@ def main():
|
|||||||
print(f"{GRY} Successfully logged in. Press Ctrl-C for a fresh prompt or Ctrl-D to exit. {RST}")
|
print(f"{GRY} Successfully logged in. Press Ctrl-C for a fresh prompt or Ctrl-D to exit. {RST}")
|
||||||
while True: # safe_input will terminate the program when the user pressed Ctrl-D
|
while True: # safe_input will terminate the program when the user pressed Ctrl-D
|
||||||
command = safe_input(f"{BLU} RCON@{RCON_ADDRESS} >{RST} ")
|
command = safe_input(f"{BLU} RCON@{RCON_ADDRESS} >{RST} ")
|
||||||
print(f"{GRY}", send_command(sock, command))
|
print(f"{GRY}", send_command(sock, command), f"{RST}")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
Reference in New Issue
Block a user