Mercurial > touhou
annotate pytouhou/options.py @ 565:5f7f859a72f9
Move CLI options to their own module.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Wed, 18 Jun 2014 22:39:11 +0200 |
parents | |
children | b2269b9c6119 |
rev | line source |
---|---|
565
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
1 # -*- encoding: utf-8 -*- |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
2 ## |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
3 ## Copyright (C) 2014 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
4 ## |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
5 ## This program is free software; you can redistribute it and/or modify |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
6 ## it under the terms of the GNU General Public License as published |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
7 ## by the Free Software Foundation; version 3 only. |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
8 ## |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
9 ## This program is distributed in the hope that it will be useful, |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
12 ## GNU General Public License for more details. |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
13 ## |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
14 |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
15 from argparse import ArgumentParser |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
16 |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
17 |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
18 def parse_arguments(defaults): |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
19 parser = ArgumentParser(description='Libre reimplementation of the Touhou 6 engine.') |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
20 |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
21 parser.add_argument('data', metavar='DAT', default=defaults['data'], nargs='*', help='Game’s data files') |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
22 parser.add_argument('-p', '--path', metavar='DIRECTORY', default='.', help='Game directory path.') |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
23 parser.add_argument('--debug', action='store_true', help='Set unlimited continues, and perhaps other debug features.') |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
24 parser.add_argument('--verbosity', metavar='VERBOSITY', choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'], help='Select the wanted logging level.') |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
25 |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
26 game_group = parser.add_argument_group('Game options') |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
27 game_group.add_argument('-s', '--stage', metavar='STAGE', type=int, default=None, help='Stage, 1 to 7 (Extra), nothing means story mode.') |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
28 game_group.add_argument('-r', '--rank', metavar='RANK', type=int, default=0, help='Rank, from 0 (Easy, default) to 3 (Lunatic).') |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
29 game_group.add_argument('-c', '--character', metavar='CHARACTER', type=int, default=0, help='Select the character to use, from 0 (ReimuA, default) to 3 (MarisaB).') |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
30 game_group.add_argument('-b', '--boss-rush', action='store_true', help='Fight only bosses.') |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
31 game_group.add_argument('--game', metavar='GAME', choices=['EoSD'], default='EoSD', help='Select the game engine to use.') |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
32 game_group.add_argument('--interface', metavar='INTERFACE', choices=['EoSD', 'Sample'], default='EoSD', help='Select the interface to use.') |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
33 game_group.add_argument('--hints', metavar='HINTS', default=None, help='Hints file, to display text while playing.') |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
34 |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
35 replay_group = parser.add_argument_group('Replay options') |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
36 replay_group.add_argument('--replay', metavar='REPLAY', help='Select a file to replay.') |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
37 replay_group.add_argument('--save-replay', metavar='REPLAY', help='Save the upcoming game into a replay file.') |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
38 replay_group.add_argument('--skip-replay', action='store_true', help='Skip the replay and start to play when it’s finished.') |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
39 |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
40 netplay_group = parser.add_argument_group('Netplay options') |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
41 netplay_group.add_argument('--port', metavar='PORT', type=int, default=0, help='Local port to use.') |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
42 netplay_group.add_argument('--remote', metavar='REMOTE', default=None, help='Remote address.') |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
43 netplay_group.add_argument('--friendly-fire', action='store_true', help='Allow friendly-fire during netplay.') |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
44 |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
45 graphics_group = parser.add_argument_group('Graphics options') |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
46 graphics_group.add_argument('--backend', metavar='BACKEND', choices=['opengl', 'sdl'], default=['opengl', 'sdl'], nargs='*', help='Which backend to use (opengl or sdl).') |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
47 graphics_group.add_argument('--fps-limit', metavar='FPS', default=-1, type=int, help='Set fps limit. A value of 0 disables fps limiting, while a negative value limits to 60 fps if and only if vsync doesn’t work.') |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
48 graphics_group.add_argument('--no-background', action='store_false', help='Disable background display (huge performance boost on slow systems).') |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
49 graphics_group.add_argument('--no-particles', action='store_false', help='Disable particles handling (huge performance boost on slow systems).') |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
50 graphics_group.add_argument('--no-sound', action='store_false', help='Disable music and sound effects.') |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
51 |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
52 opengl_group = parser.add_argument_group('OpenGL backend options') |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
53 opengl_group.add_argument('--gl-flavor', choices=['core', 'es', 'compatibility', 'legacy'], default='compatibility', help='OpenGL profile to use.') |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
54 opengl_group.add_argument('--gl-version', default=2.1, type=float, help='OpenGL version to use.') |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
55 |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
56 double_buffer = opengl_group.add_mutually_exclusive_group() |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
57 double_buffer.add_argument('--double-buffer', dest='double_buffer', action='store_true', default=None, help='Enable double buffering.') |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
58 double_buffer.add_argument('--single-buffer', dest='double_buffer', action='store_false', default=None, help='Disable double buffering.') |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
59 |
5f7f859a72f9
Move CLI options to their own module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
60 return parser.parse_args() |