Improved argument parsing.
Made launch arguments override the config's values. Added a --normal switch for overriding both debug and verbose parameters if present.
This commit is contained in:
parent
11b35c79ff
commit
932d9f45f4
@ -8,17 +8,13 @@ from settings import wolfgame as var
|
||||
|
||||
# Argument --debug means start in debug mode
|
||||
# --verbose means to print a lot of stuff (when not in debug mode)
|
||||
# --normal means to override the above and use nothing
|
||||
# Settings can be defined in the config, but launch argumentss override it
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--debug', action='store_true')
|
||||
parser.add_argument('--sabotage', action='store_true')
|
||||
parser.add_argument('--verbose', action='store_true')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
debug_mode = args.debug
|
||||
verbose = args.verbose
|
||||
sabotage = args.sabotage
|
||||
debug_mode = False
|
||||
verbose = False
|
||||
sabotage = False
|
||||
normal = False
|
||||
|
||||
# Carry over settings from botconfig into settings/wolfgame.py
|
||||
|
||||
@ -31,14 +27,29 @@ for setting, value in botconfig.__dict__.items():
|
||||
verbose = value
|
||||
if setting == "DEFAULT_MODULE":
|
||||
sabotage = value
|
||||
if setting == "NORMAL_MODE":
|
||||
normal = value
|
||||
if not setting in var.__dict__.keys():
|
||||
continue # Don't carry over config-only settings
|
||||
|
||||
# If we got that far, it's valid
|
||||
setattr(var, setting, value)
|
||||
|
||||
botconfig.DEBUG_MODE = debug_mode if not botconfig.DISABLE_DEBUG_MODE else False
|
||||
botconfig.VERBOSE_MODE = verbose
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--debug', action='store_true')
|
||||
parser.add_argument('--sabotage', action='store_true')
|
||||
parser.add_argument('--verbose', action='store_true')
|
||||
parser.add_argument('--normal', action='store_true')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.debug: debug_mode = True
|
||||
if args.verbose: verbose = True
|
||||
if args.sabotage: sabotage = True
|
||||
if args.normal: normal = True
|
||||
|
||||
botconfig.DEBUG_MODE = debug_mode if not botconfig.DISABLE_DEBUG_MODE and not normal else False
|
||||
botconfig.VERBOSE_MODE = verbose if not normal else False
|
||||
|
||||
botconfig.DEFAULT_MODULE = "sabotage" if args.sabotage else "wolfgame"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user