#! /usr/bin/env bash

function abcli_perform_action() {
    local options=$1
    local action_name=$(abcli_option "$options" action void)
    local plugin_name=$(abcli_option "$options" plugin bluer_ai)

    local function_name=${plugin_name}_action_${action_name}

    [[ $(type -t $function_name) != "function" ]] &&
        return 0

    abcli_log "✴️  action: $plugin_name: $action_name."
    $function_name "${@:2}"
}

function bluer_ai_action_git_before_push() {
    bluer_ai build_README
    [[ $? -ne 0 ]] && return 1

    [[ "$(abcli_git get_branch)" != "main" ]] &&
        return 0

    bluer_ai pypi build
}
