added listsettings option to evennia launcher, to easier inspect the values of the currently chosen settings file.

This commit is contained in:
Griatch 2015-03-07 01:37:31 +01:00
parent cde9cd36df
commit a1a821b7b5
2 changed files with 38 additions and 2 deletions

View file

@ -366,7 +366,7 @@ You are not yet logged into the game. Commands available at this point:
{wquit{n - abort the connection
First create an account e.g. with {wcreate Anna c67jHL8p{n
(If you have spaces in your name, use quotes: {wcreate "Anna the Barbarian" c67jHL8p{n
(If you have spaces in your name, use quotes: {wcreate "Anna the Barbarian" c67jHL8p{n
Next you can connect to the game: {wconnect Anna c67jHL8p{n
You can use the {wlook{n command if you want to see the connect screen again.

View file

@ -745,6 +745,32 @@ def run_dummyrunner(number_of_dummies):
except KeyboardInterrupt:
pass
def list_settings(keys):
"""
Display the server settings. We only display
the Evennia specific settings here.
"""
from importlib import import_module
from evennia.utils import evtable
evsettings = import_module(SETTINGS_DOTPATH)
if len(keys) == 1 and keys[0].upper() == "ALL":
# show a list of all keys
# a specific key
table = evtable.EvTable()
confs = dict((key,var) for key, var in evsettings.__dict__.items() if key.isupper())
for i in range(0, len(confs), 4):
table.add_row(*confs.keys()[i:i+4])
else:
# a specific key
table = evtable.EvTable(width=131)
keys = [key.upper() for key in keys]
confs = dict((key,var) for key, var in evsettings.__dict__.items() if key in keys)
for key, val in confs.items():
table.add_row(key, str(val))
print table
def run_menu():
"""
This launches an interactive menu.
@ -898,6 +924,8 @@ def main():
help="Start given processes in interactive mode.")
parser.add_argument('--init', action='store', dest="init", metavar="name",
help="Creates a new game directory 'name' at the current location.")
parser.add_argument('-l', nargs='+', action='store', dest='listsetting', metavar="key",
help="List values for server settings. Use 'all' to list all available keys.")
parser.add_argument('--profiler', action='store_true', dest='profiler', default=False,
help="Start given server component under the Python profiler.")
parser.add_argument('--dummyrunner', nargs=1, action='store', dest='dummyrunner', metavar="N",
@ -914,25 +942,29 @@ def main():
args, unknown_args = parser.parse_known_args()
# handle arguments
option, service = args.option, args.service
# make sure we have everything
check_main_evennia_dependencies()
if not args:
# show help pane
print CMDLINE_HELP
sys.exit()
elif args.init:
# initialization of game directory
create_game_directory(args.init)
print CREATED_NEW_GAMEDIR.format(gamedir=args.init,
settings_path=os.path.join(args.init, SETTINGS_PATH))
sys.exit()
if args.show_version:
# show the version info
print show_version_info(option=="help")
sys.exit()
if args.altsettings:
# use alternative settings file
sfile = args.altsettings[0]
global SETTINGSFILE, SETTINGS_DOTPATH
SETTINGSFILE = sfile
@ -943,6 +975,10 @@ def main():
# launch the dummy runner
init_game_directory(CURRENT_DIR, check_db=True)
run_dummyrunner(args.dummyrunner[0])
elif args.listsetting:
# display all current server settings
init_game_directory(CURRENT_DIR, check_db=False)
list_settings(args.listsetting)
elif option == 'menu':
# launch menu for operation
init_game_directory(CURRENT_DIR, check_db=True)