5 from naja.attrdict import AttrDict
6 from naja.constants import DEFAULTS
14 Parse arguments and store them in the options dictionary.
16 Note: If you add arguments, you need to add an appropriate default to the
19 options.update(DEFAULTS)
21 options.debug = 'DEBUG' in os.environ
23 parser = optparse.OptionParser()
24 parser.add_option('--no-sound',
25 dest='sound', action='store_false', default=True,
26 help='Disable all sound, including music')
28 parser.add_option('--no-music',
29 dest='music', action='store_false', default=True,
30 help='Disable music (but not sound)')
32 parser.add_option("--save-location", default=_get_default_save_location(),
33 dest="save_location", help="Saved game location")
36 parser.add_option('--initial-bits', type=int,
37 help='Initial player bits')
38 parser.add_option('--cheat-enabled', default=False,
40 help='For those too lazy to type the KONAMI code')
41 parser.add_option('--deck', default=None,
42 help='Start with a new game for a specific deck')
43 parser.add_option('--load', default=None,
44 help='Start with a specific save game loaded')
46 opts, _ = parser.parse_args(args)
49 if getattr(opts, k, None) is not None:
50 options[k] = getattr(opts, k)
53 def _get_default_save_location():
54 """Return a default save game location."""
56 if sys.platform.startswith("win"):
57 if "APPDATA" in os.environ:
58 return os.path.join(os.environ["APPDATA"], app)
59 return os.path.join(os.path.expanduser("~"), "." + app)
60 elif 'XDG_DATA_HOME' in os.environ:
61 return os.path.join(os.environ["XDG_DATA_HOME"], app)
62 return os.path.join(os.path.expanduser("~"), ".local", "share", app)