summaryrefslogtreecommitdiffstats
path: root/gamechestcli/gamechest/cliactions/run.py
diff options
context:
space:
mode:
Diffstat (limited to 'gamechestcli/gamechest/cliactions/run.py')
-rw-r--r--gamechestcli/gamechest/cliactions/run.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/gamechestcli/gamechest/cliactions/run.py b/gamechestcli/gamechest/cliactions/run.py
index e69de29..b5369aa 100644
--- a/gamechestcli/gamechest/cliactions/run.py
+++ b/gamechestcli/gamechest/cliactions/run.py
@@ -0,0 +1,31 @@
+import subprocess
+import sys
+
+from .. import paths
+from ..gamedb import GameDB
+from ..statusdb import StatusDB
+
+
+def run_game(game_db, profile_id, game_info):
+ command = game_db.get_game_command(profile_id, game_info['id'])
+ #tools_bin_path = paths.get_games_saves_tools_bin_path()
+ #new_env = dict(os.environ)
+ #new_env['PATH'] = f'{tools_bin_path}:{new_env["PATH"]}'
+ # path to mod/run scripts are already prepended by get_game_command, no
+ # need to modify the path environment variable.
+ subprocess.run(command)
+
+
+def run(game_id, profile_id):
+ game_db = GameDB()
+ status_db = StatusDB()
+ game_info = game_db.get_game_info(game_id)
+ if not status_db.is_installed(game_info):
+ # games is already installed
+ print('Game', game_id, 'is not installed, aborting.', file=sys.stderr)
+ return
+ run_game(game_db, profile_id, game_info)
+
+
+if __name__ == "__main__":
+ run(*sys.argv[1:])