# Author:       Li Junhao           l@x-cmd.com
# shellcheck    shell=sh            disable=SC3043,SC2164     # xrc

# license:      GPLv3

# Better But Will Be Slower.
# Move the files as safe as possible in a batch.

# mv a/b/c.txt a/b/d.txt a/c/a.txt  dst/
# mv -p b/c.txt b/d/.txt c/a.txt    dst/

xrc:mod:lib     mv      colon utils

___x_cmd_mv(){
    local op="$1"
    case "$op" in
        :*)
            shift;
            ___x_cmd_mv_colon "${op#:}" "$@"
            return
            ;;
        -h|--help)  ___x_cmd help -m mv;    return ;;
    esac

    case "$#" in
        0)
            printf "%s\n" "TODO: Will Implement Pipe DSL for mv"
            return 1
            ;;
        1)
            ___x_cmd_mv_from_pipe "$1"
            return
            ;;
    esac

    local lastarg;  eval 'lastarg="$'$#'"'
    ___x_cmd ensurefp "$lastarg"
    ___x_cmd_cmds mv "$@"
    return
}

___x_cmd_mv_help(){
    ___x_cmd help -m mv
    return 1
}

xrc setmain ___x_cmd_mv
