summarylogtreecommitdiffstats
path: root/Unciv.sh
blob: dabc2636aec8a1c9bd1eb1fdad983fd9e573bac6 (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
#!/bin/sh

export PATH=/usr/lib/jvm/java-11-openjdk/bin/:$PATH
CONFIG_DIR="$HOME/.local/share/Unciv"

USAGE="Unciv [--help | -h | --config-dir PATH]

Run the Unciv game.

With '--help' or '-h', show this help info and exit.

With '--config-dir PATH', use/make configuration files in PATH instead
of the default of '$CONFIG_DIR'.

"

usage() {
    echo "$USAGE"
    exit 0
}

fail() {
    echo "Error: $1"
    usage
    exit 1
}

if [ "$#" -gt "0" ]; then
    case "$1" in
        --help|-h)
            shift
            usage
            ;;
        --config-dir)
            CONFIG_DIR="$2"
            shift 2
            ;;
    esac
    shift
fi
if ! [ "$#" -eq "0" ]; then
    fail "Unknown argument(s): $*"
fi

mkdir -p "$CONFIG_DIR"
cd "$CONFIG_DIR" || fail "Could not 'cd' to '$CONFIG_DIR'"
java -jar /usr/share/Unciv/Unciv.jar