summaryrefslogtreecommitdiffstats
path: root/gamechestcli/gamechest/cliactions/install.py
diff options
context:
space:
mode:
Diffstat (limited to 'gamechestcli/gamechest/cliactions/install.py')
-rw-r--r--gamechestcli/gamechest/cliactions/install.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/gamechestcli/gamechest/cliactions/install.py b/gamechestcli/gamechest/cliactions/install.py
new file mode 100644
index 0000000..ed62760
--- /dev/null
+++ b/gamechestcli/gamechest/cliactions/install.py
@@ -0,0 +1,31 @@
+import functools
+
+from .. import gamedb
+from .. import paths
+from .. import processor
+from ..runners.install import Install
+from ..statusdb import StatusDB
+
+
+def install_game(status_db, game_info):
+ remote_basedir = paths.get_remote_basedir()
+ source = f'{remote_basedir}/{game_info["package_name"]}'
+ dest = paths.get_games_install_basedir()
+ title = 'Installing game...'
+ task = functools.partial(Install, source, dest)
+ processor.process_task(title, task)
+ status_db.set_installed(game_info)
+
+
+def install(game_id):
+ game_info = gamedb.get_game_info(game_id)
+ status_db = StatusDB()
+ if status_db.is_installed(game_info):
+ # games is already installed
+ return
+ install_game(status_db, game_info)
+
+
+if __name__ == "__main__":
+ import sys
+ install(sys.argv[1])