<commit_before>source "${SANDBIN_HOME}/scripts/lib/colors.lib.zsh"
source "${SANDBIN_HOME}/scripts/lib/git-functions.lib.zsh"

function usage-changelog() {
    printf "'${YELLOW}gitbox changelog${NORMAL}' updates changelog information\n"
    printf "${YELLOW}%s${NORMAL}\n" "usage: gitbox changelog [-h, --header <message> | -h, --help]"
}

function gitbox-changelog() {

    while [[ $# > 0 ]]; do
        key="$1"

        case $key in

            -h|--header)
                message="$2"
                shift
            ;;
            -h|--help)
                usage-changelog
                exit 0
            ;;
            *)
                printf "${RED}%s${NORMAL}\n" "Ouch! Unknown option '$key'. Please try agan!"
                usage-changelog
                exit 1
            ;;
        esac

        shift;
    done

    if [ $(git_distance_from_last_tag) = 0 ]; then
        printf "${RED}%s${NORMAL}\n" "Sorry! There aren't commits yet since the last tag"
    else
        print_changelog_head "$message"
        printf "%s\n\n" "$(git_changelog)"
    fi
}

function print_changelog_head() {
    local message="$1"

    branch_name=$(git_branch_name)
    case $branch_name in
        feature/*)
            printf "## WIP: %s %s\n" "${branch_name##feature/}" "$message"
        ;;
        release/*)
            printf "## %s - %s\n" "${branch_name##release/}" "$message"
        ;;
        develop)
            printf "## WIP: %s %s\n" "develop" "$message"
        ;;
        master)
            printf "## %s\n" "$(git_last_tag_subject)"
        ;;<commit_msg>Change the subject flag in order to not collide with the help flag<commit_after>source "${SANDBIN_HOME}/scripts/lib/colors.lib.zsh"
source "${SANDBIN_HOME}/scripts/lib/git-functions.lib.zsh"

function usage-changelog() {
    printf "'${YELLOW}gitbox changelog${NORMAL}' updates changelog information\n"
    printf "${YELLOW}%s${NORMAL}\n" "usage: gitbox changelog [-s, --subject <message> | -h, --help]"
}

function gitbox-changelog() {

    while [[ $# > 0 ]]; do
        key="$1"

        case $key in

            -s|--subject)
                subject="$2"
                shift
            ;;
            -h|--help)
                usage-changelog
                exit 0
            ;;
            *)
                printf "${RED}%s${NORMAL}\n" "Ouch! Unknown option '$key'. Please try agan!"
                usage-changelog
                exit 1
            ;;
        esac

        shift;
    done

    if [ $(git_distance_from_last_tag) = 0 ]; then
        printf "${RED}%s${NORMAL}\n" "Sorry! There aren't commits yet since the last tag"
    else
        print_changelog_head "$subject"
        printf "%s\n\n" "$(git_changelog)"
    fi
}

function print_changelog_head() {
    local subject="$1"

    branch_name=$(git_branch_name)
    case $branch_name in
        feature/*)
            printf "## WIP: %s %s\n" "${branch_name##feature/}" "$subject"
        ;;
        release/*)
            printf "## %s - %s\n" "${branch_name##release/}" "$subject"
        ;;
        develop)
            printf "## WIP: %s %s\n" "develop" "$subject"
        ;;
        master)
            printf "## %s\n" "$(git_last_tag_subject)"
        ;;
{'fraction_non_alphanumeric': 0.15546608857231342, 'fraction_numerical': 0.004335707649427067, 'mean_word_length': 1.7725321888412018, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '955963', 'n_tokens_mistral': 1070, 'n_tokens_neox': 1003, 'n_words': 226}