summaryrefslogblamecommitdiffstats
path: root/main.sh
blob: 63c43ffb6be91a16aba96e0a87dbda9ae1d3b9e4 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11










                                                                      

                                          

      


            
                                   

                                           

                                         

                                          


                                               
          

            

      

                          


                                
 
                                     
                         

                                     

                                      

                                         

                                       

                                      

                                    

                                         
                                    
                      



                                          







                                            
        

                                             


      
         
##
# 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 "$@"
        elif [[ "$cmd" == "clone" ]]; then
            systr_clone "$@"
        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" == "clone" ]]; then
        systr_clone "$@"
    elif [[ "$cmd" == "checkout" ]]; then
        systr_checkout "$@"
    elif [[ "$cmd" == "commit" ]]; then
        systr_commit "$@"
    elif [[ "$cmd" == "reset" ]]; then
        systr_reset "$@"
    elif [[ "$cmd" == "tag" ]]; then
        systr_repo_tag "$@"
    elif [[ "$cmd" == "shortlog" ]]; then
        systr_short_log "$@"
    elif [[ "$cmd" == "log" ]]; then
        systr_log "$@"
    elif [[ "$cmd" == "shortdiff" ]]; then
        systr_short_diff "$@"
    elif [[ "$cmd" == "diff" ]]; then
        systr_diff "$@"
    elif [[ "$cmd" == "merge" ]]; then
        systr_merge "$@"
    elif [[ "$cmd" == "update" ]]; then
        systr_merge "TRAC" "$@"
    elif [[ "$cmd" == "apply-merge" ]]; then
        systr_merge_finish "$MERG" "$@"
    elif [[ "$cmd" == "abort-merge" ]]; then
        systr_merge_abort "$@"
    else
        echo "Fatal: $cmd not recognized" >&2
        exit 1
    fi
}

main "$@"