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')
39 opts, _ = parser.parse_args(args)
42 if getattr(opts, k, None) is not None:
43 options[k] = getattr(opts, k)
44 options['save_location'] = opts.save_location
47 def _get_default_save_location():
48 """Return a default save game location."""
50 if sys.platform.startswith("win"):
51 if "APPDATA" in os.environ:
52 return os.path.join(os.environ["APPDATA"], app)
53 return os.path.join(os.path.expanduser("~"), "." + app)
54 elif 'XDG_DATA_HOME' in os.environ:
55 return os.path.join(os.environ["XDG_DATA_HOME"], app)
56 return os.path.join(os.path.expanduser("~"), ".local", "share", app)