summaryrefslogtreecommitdiffstats
path: root/main.sh
blob: 0c3d3dfdefc51782543fb68433b14a7cabf4e5eb (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
53
54
55
56
57
58
##
# 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 "$@"
        elif [[ "$cmd" == "init" ]]; then
            systr_init "$@"
        else
            echo "Fatal: not in a worktree" >&2
            exit 1
        fi

        exit
    fi

    read path <.systr/path
    read BASE <.systr/BASE
    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 "$@"