delete.bash

#!/usr/bin/env bash

delete(){
    n="$(color_li 0)"
    d="$(color_li 1)"
    f="${cOff}"
    prompt_choose_function \
        "# bent delete [command]" \
        "'Other delete features have not been implemented yet" \
        "delete_version" "version" "Delete a version of your project" \
    ;

}
delete_help(){
    run delete
}
delete_v(){
    run delete version
}

delete_version(){
    is_project_dir || return;
    
    header "Available version: "
    msg
    run show versions
    msg_instruct "[ctrl-c] to cancel"
    prompt_quit "Type version to delete: " delVersion \
        && return

    msg_notice "Deletes on the remote host as well"
    prompt_quit "Confirm version to delete: " delVersionConfirm \
        && return
    msg

    if [[ $delVersion != $delVersionConfirm ]];then
        msg "Those did not match. Try again."
        msg
        return;
    fi

    git branch -D $delVersion
    git branch -d -r origin/$delVersion
    #@TODO maybe make remote deletion optional??
    git push origin :$delVersion
    
    #@TODO provide instructions on how to restore a deleted branch
    #@TODO add archive_version to Git Bent feature (Create a tag at archive/month-year/branch-name, push, then delete the branch... or something)

}