summaryrefslogtreecommitdiffstats
path: root/gamechest/cli.py
blob: d0b457e43b61986453f10cc77b5d0670c986cf2a (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!python3

'''
Usage: gamechest.py --gamelist=GAMELIST.YAML --gamedir=GAMEDIR
'''

import logging
import os
from logging import debug, info, warning, critical


import docopt
import yaml
import gamemanager


def main():
    logging.basicConfig(level=logging.DEBUG)
    logging.getLogger().handlers[0].setFormatter(logging.Formatter(
        "gamechest: %(levelname)s: %(funcName)s:%(lineno)s: %(message)s"))

    args = docopt.docopt(__doc__)
    debug('args: %s', args)

    gamelist_dir = (
            os.path.dirname(args['--gamelist'])
            + '/.'
            + os.path.basename(args['--gamelist'])
            + '.d'
    )
    gamelist = GameList(args['--gamelist'], args['--gamedir'])

    builder = gtk.Builder()
    builder.add_from_file('gamechest.glade')
    builder.connect_signals(
        Handler(builder, gamelist, gamelist_dir, args['--gamedir']))

    window = builder.get_object('window2')
    window.show_all()

    gamelist_store = builder.get_object('gamelist_store')
    gamelist_store.clear()
    for index, game in enumerate(gamelist.yaml_data['games']):
        gamelist_store.append((False, game['title'], index))
    info('%d games loaded', len(gamelist.yaml_data['games']))

    gtk.main()

def main():
    import sys
    gamelist_path = sys.argv[1]
    gamedir_path = sys.argv[2]
    action_name = sys.argv[3]
    game_name = sys.argv[4] # used to determine game_id

    # TODO:
    # - parse gamelist (conf)
    # - parse package installed info or empty (conf)
    # - follow action (install, remove, update)
    # - use name on game name
    # - update status bar from polling (with a timer, or a simple sleep)
    # - if run, run the game.


if __name__ == '__main__':
    main()