summaryrefslogtreecommitdiffstats
path: root/gamechestcli/gamechest/cliactions/remove.py
blob: c187ae13f5061a0d114b0ffedb7ea145cc675bdc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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])