summaryrefslogtreecommitdiffstats
path: root/main.sh
blob: a23a9890acb8d8fa9d4c20bb65c73bef1509bbac (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
42
43
44
45
46
47
48
49
50
51
52
##
# systrunk <command> [<options>, ...]
#
# A version control system powered by rsync, focused on tracking large
# directory trees with large files, even binary files; system images.
#
# Main function, decide what to do ...
##
function main
{
    if [ $# -eq 0 ]; then
        echo "Fatal: no command given" >&2
        exit 1
    fi

    cmd="$1"
    shift

    if [ ! -f ".systr/BASE" ]; then
        if [[ "$cmd" == "checkout" ]]; then
            systr_checkout "$@"
            exit
        fi
    fi

    read path <.systr/path || echo "Fatal: not in a worktree" >&2
    read BASE <.systr/BASE || exit 1
    read TRAC <.systr/TRAC
    read MERG <.systr/MERG
    read updated <.systr/updated

    if [[ "$cmd" == "status" ]]; then
        systr_status "$@"
    elif [[ "$cmd" == "init" ]]; then
        systr_init "$@"
    elif [[ "$cmd" == "checkout" ]]; then
        systr_checkout "$@"
    elif [[ "$cmd" == "commit" ]]; then
        systr_commit "$@"
    elif [[ "$cmd" == "tag" ]]; then
        systr_repo_tag "$@"
    elif [[ "$cmd" == "shortlog" ]]; then
        systr_short_log "$@"
    elif [[ "$cmd" == "log" ]]; then
        systr_log "$@"
    else
        echo "Fatal: $cmd not recognized" >&2
        exit 1
    fi
}

main "$@"