summaryrefslogtreecommitdiff
path: root/src/hiccup/hiccup.py
blob: 673e697af1ac6550e01f62a1ff748b603b9de84e (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
#!/usr/bin/env python3
import argparse
import os
from .helpers import DistroHelper, DistroNotSupportedError, get_distro_id


def run():
    CONFIG_FILE = os.path.join(os.environ["XDG_CONFIG_HOME"], "hiccup/config.json")
    OS_RELEASE_PATH = "/etc/os-release"

    current_distro = str()
    try:
        current_distro = get_distro_id(OS_RELEASE_PATH)
    except DistroNotSupportedError:
        pass
    distro = DistroHelper(current_distro, CONFIG_FILE)

    parser = argparse.ArgumentParser(
        description="a python script to help keep you up to date"
    )
    parser.add_argument(
        "--cleanonly",
        "-c",
        action="store_true",
        default=False,
        dest="clean_only",
        help="cleanup unneeded dependencies",
    )
    parser.add_argument(
        "--systemonly",
        "-s",
        action="store_true",
        default=False,
        dest="system_only",
        help="only update through the system's package manager",
    )
    parser.add_argument(
        "--otheronly",
        "-o",
        action="store_true",
        default=False,
        dest="other_only",
        help="only update misc package managers",
    )
    parser.add_argument(
        "--no-output" "-n",
        action="store_true",
        default=False,
        dest="output",
        help="silence output of misc package managers",
    )
    args = parser.parse_args()

    if args.clean_only:
        return distro.cleanup_system()
    elif args.system_only:
        return distro.update_system()
    elif args.other_only:
        return distro.update_other(args.output)

    return distro.update_all(args.output)