[game-data-packager] 02/08: Python gdp: accept --no-install, etc., before or after game
Simon McVittie
smcv at debian.org
Thu Jan 15 09:40:15 UTC 2015
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to branch master
in repository game-data-packager.
commit 042909df74b16e880e454a4bdf1339c676124dbc
Author: Simon McVittie <smcv at debian.org>
Date: Wed Jan 14 09:13:51 2015 +0000
Python gdp: accept --no-install, etc., before or after game
---
lib/game_data_packager/__init__.py | 46 ++++++++++++++++++++--------------
lib/game_data_packager/games/rott.py | 4 +--
lib/game_data_packager/games/tyrian.py | 4 +--
lib/game_data_packager/games/wolf3d.py | 4 +--
4 files changed, 33 insertions(+), 25 deletions(-)
diff --git a/lib/game_data_packager/__init__.py b/lib/game_data_packager/__init__.py
index 14a4660..1a7cba0 100644
--- a/lib/game_data_packager/__init__.py
+++ b/lib/game_data_packager/__init__.py
@@ -1360,11 +1360,12 @@ class GameData(object):
def get_control_template(self, package):
return os.path.join(DATADIR, package.name + '.control.in')
- def add_parser(self, parsers):
+ def add_parser(self, parsers, base_parser):
parser = parsers.add_parser(self.shortname,
help=self.longname, aliases=self.packages.keys(),
description=self.help_text,
- formatter_class=argparse.RawDescriptionHelpFormatter)
+ formatter_class=argparse.RawDescriptionHelpFormatter,
+ parents=(base_parser,))
parser.add_argument('paths', nargs='*',
metavar='DIRECTORY|FILE',
help='Files to use in constructing the .deb')
@@ -1615,31 +1616,38 @@ def load_yaml_games(workdir=None):
def run_command_line():
logger.debug('Arguments: %r', sys.argv)
- parser = argparse.ArgumentParser(prog='game-data-packager',
- description='Package game files.')
-
- game_parsers = parser.add_subparsers(dest='shortname',
- title='supported games', metavar='GAME')
-
- games = load_yaml_games(os.environ.get('WORKDIR', None))
-
- for g in sorted(games.keys()):
- games[g].add_parser(game_parsers)
+ base_parser = argparse.ArgumentParser(prog='game-data-packager',
+ description='Package game files.',
+ add_help=False)
# Misc options
- parser.add_argument('-i', '--install', action='store_true',
+ group = base_parser.add_mutually_exclusive_group()
+ group.add_argument('-i', '--install', action='store_true',
help='install the generated package')
- parser.add_argument('-n', '--no-install', action='store_false',
+ group.add_argument('-n', '--no-install', action='store_false',
dest='install',
help='do not install the generated package (requires -d, default)')
- parser.add_argument('-d', '--destination', metavar='OUTDIR',
+ base_parser.add_argument('-d', '--destination', metavar='OUTDIR',
help='write the generated .deb(s) to OUTDIR')
- parser.add_argument('-z', '--compress', action='store_true',
+
+ group = base_parser.add_mutually_exclusive_group()
+ group.add_argument('-z', '--compress', action='store_true',
default=None,
- help='compress generated .deb (default unless -i is used)')
- parser.add_argument('--no-compress', action='store_false',
+ help='compress generated .deb (default if -d is used)')
+ group.add_argument('--no-compress', action='store_false',
dest='compress',
- help='do not compress generated .deb (default with -i)')
+ help='do not compress generated .deb (default without -d)')
+
+ parser = argparse.ArgumentParser(prog='game-data-packager',
+ description='Package game files.', parents=(base_parser,))
+
+ game_parsers = parser.add_subparsers(dest='shortname',
+ title='supported games', metavar='GAME')
+
+ games = load_yaml_games(os.environ.get('WORKDIR', None))
+
+ for g in sorted(games.keys()):
+ games[g].add_parser(game_parsers, base_parser)
parsed = parser.parse_args()
diff --git a/lib/game_data_packager/games/rott.py b/lib/game_data_packager/games/rott.py
index 4df8941..63371fb 100644
--- a/lib/game_data_packager/games/rott.py
+++ b/lib/game_data_packager/games/rott.py
@@ -22,8 +22,8 @@ from .. import GameData
logger = logging.getLogger('game-data-packager.games.rott')
class ROTTGameData(GameData):
- def add_parser(self, parsers):
- parser = super(ROTTGameData, self).add_parser(parsers)
+ def add_parser(self, parsers, base_parser):
+ parser = super(ROTTGameData, self).add_parser(parsers, base_parser)
parser.add_argument('-f', action='append', dest='paths',
metavar='1rott13.zip', help='Path to 1rott13.zip')
parser.add_argument('-w', dest='download', action='store_true',
diff --git a/lib/game_data_packager/games/tyrian.py b/lib/game_data_packager/games/tyrian.py
index 4cb766c..0db7cb6 100644
--- a/lib/game_data_packager/games/tyrian.py
+++ b/lib/game_data_packager/games/tyrian.py
@@ -22,8 +22,8 @@ from .. import GameData
logger = logging.getLogger('game-data-packager.games.tyrian')
class TyrianGameData(GameData):
- def add_parser(self, parsers):
- parser = super(TyrianGameData, self).add_parser(parsers)
+ def add_parser(self, parsers, base_parser):
+ parser = super(TyrianGameData, self).add_parser(parsers, base_parser)
parser.add_argument('-f', action='append', dest='paths',
metavar='tyrian21.zip', help='Path to tyrian21.zip')
parser.add_argument('-w', dest='download', action='store_true',
diff --git a/lib/game_data_packager/games/wolf3d.py b/lib/game_data_packager/games/wolf3d.py
index 83f061c..c6e5680 100644
--- a/lib/game_data_packager/games/wolf3d.py
+++ b/lib/game_data_packager/games/wolf3d.py
@@ -22,8 +22,8 @@ from .. import GameData
logger = logging.getLogger('game-data-packager.games.wolf3d')
class Wolf3DGameData(GameData):
- def add_parser(self, parsers):
- parser = super(Wolf3DGameData, self).add_parser(parsers)
+ def add_parser(self, parsers, base_parser):
+ parser = super(Wolf3DGameData, self).add_parser(parsers, base_parser)
parser.add_argument('-f', action='append', dest='paths',
metavar='1wolf14.zip', help='Path to 1wolf14.zip')
parser.add_argument('-w', dest='download', action='store_true',
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/game-data-packager.git
More information about the Pkg-games-commits
mailing list