diff options
Diffstat (limited to 'gamechestcli/gamechest/cliactions/remove.py')
-rw-r--r-- | gamechestcli/gamechest/cliactions/remove.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/gamechestcli/gamechest/cliactions/remove.py b/gamechestcli/gamechest/cliactions/remove.py new file mode 100644 index 0000000..c187ae1 --- /dev/null +++ b/gamechestcli/gamechest/cliactions/remove.py @@ -0,0 +1,38 @@ +import contextlib +import functools +import selectors + +from rich.progress import Progress as RichProgress +from rich import print + +from .. import gamedb +from .. import paths +from .. import processor +from ..runners.remove import Remove +from ..statusdb import StatusDB + + +def remove_game(status_db, game_info): + remote_basedir = paths.get_remote_basedir() + path = ( + paths.get_games_install_basedir() + / status_db.get_installed_game_name(game_info['id']) + ) + title = 'Removing game...' + task = functools.partial(Remove, path) + processor.process_task(title, task) + status_db.set_uninstalled(game_info) + + +def remove(game_id): + game_info = gamedb.get_game_info(game_id) + status_db = StatusDB() + if status_db.is_installed(game_info): + remove_game(status_db, game_info) + else: + print('Game not installed') + + +if __name__ == "__main__": + import sys + remove(sys.argv[1]) |