aboutsummaryrefslogtreecommitdiff
path: root/modpackman.py
blob: 6e237924a42ccc19462956982818160572901c1d (plain) (blame)
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
#!/usr/bin/env python3
import argparse
import os
import sys
import shutil

import util


parser = argparse.ArgumentParser(
    description="A Simple Git-Based Modpack Manager",
    formatter_class=argparse.RawDescriptionHelpFormatter,
    epilog='''\
Available commands:
    install          : Downloads mods listed in version.txt and populates the mods folder specified in pack-location.txt
    apply_updates    : Using the urls in mods.txt, repopulates version.txt to reflect the most recent mod versions
    check_updates    : Compares version.txt and mods.txt to see if any mods can be updated
''')

parser.add_argument('command',
    nargs='?',
    default='install',
    help="The action to perform (default: install)")

if __name__ == "__main__":
    args = parser.parse_args()
    config = util.load_config()
    mods = config['mods']
    pack = config['pack']

    # run the command
    if args.command == "install":
        util.install("version.txt", pack["whitelist"], pack['location'])
    elif args.command == "apply_updates":
        util.apply_updates(mods, "version.txt", pack["game_version"])
    elif args.command == "check_updates":
        util.check_updates(mods, "version.txt", pack["game_version"])
    else:
        print("Error: command \"" + args.command + "\" does not exist")
        parser.print_help()
        sys.exit(1)