From 6b710bf06f00a59b611d8f15ecb9b53f5e7b3eda Mon Sep 17 00:00:00 2001 From: Mathieu Comandon Date: Tue, 29 Dec 2015 18:42:33 -0800 Subject: [PATCH] Add option to list installed games (Fixes #238) --- bin/lutris | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/bin/lutris b/bin/lutris index 7831f3ba2..6e2787ddc 100755 --- a/bin/lutris +++ b/bin/lutris @@ -71,18 +71,20 @@ logger.setLevel(logging.ERROR) # Support for command line options. parser = optparse.OptionParser(version="%prog " + VERSION) -parser.add_option("-v", "--verbose", action="store_true", - dest="verbose", help="Verbose output") -parser.add_option("-d", "--debug", action="store_true", - dest="debug", help="Show debug messages") +parser.add_option("-v", "--verbose", action="store_true", dest="verbose", + help="Verbose output") +parser.add_option("-d", "--debug", action="store_true", dest="debug", + help="Show debug messages") parser.add_option("-i", "--install", dest="installer_file", help="Install a game from a yml file") -parser.add_option("-l", "--list-games", action="store_true", - help="List all games in database") +parser.add_option("-l", "--list-games", action="store_true", dest="list_games", + help="List games in database") +parser.add_option("-o", "--installed", action="store_true", dest="list_installed", + help="Only list installed games") parser.add_option("-s", "--list-steam", action="store_true", help="List Steam (Windows) games") -parser.add_option("-j", "--json", action="store_true", - dest="json", help="Display the list of games in JSON format") +parser.add_option("-j", "--json", action="store_true", dest="json", + help="Display the list of games in JSON format") parser.add_option("--reinstall", action="store_true", help="Reinstall game") (options, args) = parser.parse_args() @@ -93,9 +95,12 @@ if options.debug: logger.setLevel(logging.DEBUG) if options.list_games: + game_list = pga.get_games() + if options.list_installed: + game_list = [game for game in game_list if game['installed']] if options.json: games = [] - for game in pga.get_games(): + for game in game_list: games.append({ 'id': game['id'], 'slug': game['slug'], @@ -105,7 +110,7 @@ if options.list_games: }) print json.dumps(games, indent=2).encode('utf-8') else: - for game in pga.get_games(): + for game in game_list: print u"{:4} | {:<40} | {:<40} | {:<15} | {:<64}".format( game['id'], game['name'][:40],