refactor(omb-deprecate): Rename "_omb_{util_defun_deprecate => deprecate_function}"

This commit is contained in:
Koichi Murase
2022-01-16 10:47:22 +09:00
parent e2820dfdd8
commit 9788583d4e
3 changed files with 43 additions and 42 deletions

View File

@@ -1,5 +1,21 @@
#! bash oh-my-bash.module
function _omb_deprecate_function__message {
local old=$1 new=$2
local v=__omb_util_DeprecateFunction_$old; v=${v//[!a-zA-Z0-9_]/'_'}
[[ ${!v+set} ]] && return 0
printf 'warning (oh-my-bash): %s\n' "\`$old' is deprecated. Use \`$new'." >&2
printf -v "$v" done
}
function _omb_deprecate_function {
local warning=
((_omb_version>=$1)) &&
warning='_omb_deprecate_function__message "$2" "$3"; '
builtin eval -- "function $2 { $warning$3 \"\$@\"; }"
}
# deprecate functions
# oh-my-bash.sh -- These functions were originally used to find
@@ -22,22 +38,22 @@ is_alias() {
# lib/utils.sh -- Logging functions
_omb_util_defun_deprecate 20000 type_exists _omb_util_binary_exists
_omb_deprecate_function 20000 type_exists _omb_util_binary_exists
_omb_util_defun_deprecate 20000 e_header _omb_log_header
_omb_util_defun_deprecate 20000 e_arrow _omb_log_arrow
_omb_util_defun_deprecate 20000 e_success _omb_log_success
_omb_util_defun_deprecate 20000 e_error _omb_log_error
_omb_util_defun_deprecate 20000 e_warning _omb_log_warning
_omb_util_defun_deprecate 20000 e_underline _omb_log_underline
_omb_util_defun_deprecate 20000 e_bold _omb_log_bold
_omb_util_defun_deprecate 20000 e_note _omb_log_note
_omb_deprecate_function 20000 e_header _omb_log_header
_omb_deprecate_function 20000 e_arrow _omb_log_arrow
_omb_deprecate_function 20000 e_success _omb_log_success
_omb_deprecate_function 20000 e_error _omb_log_error
_omb_deprecate_function 20000 e_warning _omb_log_warning
_omb_deprecate_function 20000 e_underline _omb_log_underline
_omb_deprecate_function 20000 e_bold _omb_log_bold
_omb_deprecate_function 20000 e_note _omb_log_note
# themes/*
_omb_util_defun_deprecate 20000 prompt_command _omb_theme_PROMPT_COMMAND
_omb_util_defun_deprecate 20000 prompt _omb_theme_PROMPT_COMMAND
_omb_util_defun_deprecate 20000 prompt_setter _omb_theme_PROMPT_COMMAND
_omb_util_defun_deprecate 20000 pure_setter _omb_theme_PROMPT_COMMAND # pure, gallifrey
_omb_util_defun_deprecate 20000 dulcie_setter _omb_theme_PROMPT_COMMAND # dulcie
_omb_util_defun_deprecate 20000 _brainy_setter _omb_theme_PROMPT_COMMAND # brainy
_omb_util_defun_deprecate 20000 set_bash_prompt _omb_theme_PROMPT_COMMAND # agnoster
_omb_deprecate_function 20000 prompt_command _omb_theme_PROMPT_COMMAND
_omb_deprecate_function 20000 prompt _omb_theme_PROMPT_COMMAND
_omb_deprecate_function 20000 prompt_setter _omb_theme_PROMPT_COMMAND
_omb_deprecate_function 20000 pure_setter _omb_theme_PROMPT_COMMAND # pure, gallifrey
_omb_deprecate_function 20000 dulcie_setter _omb_theme_PROMPT_COMMAND # dulcie
_omb_deprecate_function 20000 _brainy_setter _omb_theme_PROMPT_COMMAND # brainy
_omb_deprecate_function 20000 set_bash_prompt _omb_theme_PROMPT_COMMAND # agnoster

View File

@@ -80,21 +80,6 @@ function _omb_util_defun_print {
builtin eval -- "function $1 { local $3; $2 \"\$@\" && printf '%s\n' \"\${$3}\"; }"
}
function __omb_util_defun_deprecate__message {
local old=$1 new=$2
local v=__omb_util_DeprecateFunction_$old; v=${v//[!a-zA-Z0-9_]/'_'}
[[ ${!v+set} ]] && return 0
printf 'warning (oh-my-bash): %s\n' "\`$old' is deprecated. Use \`$new'." >&2
printf -v "$v" done
}
function _omb_util_defun_deprecate {
local warning=
((_omb_version >= $1)) &&
warning='__omb_util_defun_deprecate__message "$2" "$3"; '
builtin eval -- "function $2 { $warning$3 \"\$@\"; }"
}
#
# Test whether a command---either an alias, a keyword, a function, a builtin,
# or a file---is defined.

View File

@@ -438,11 +438,11 @@ _omb_util_defun_print _omb_prompt_{print,get}_rvm rvm
_omb_util_defun_print _omb_prompt_{print,get}_chruby chruby
_omb_util_defun_print _omb_prompt_{print,get}_ruby_env ruby_env
_omb_util_defun_deprecate 20000 rbfu_version_prompt _omb_prompt_print_rbfu
_omb_util_defun_deprecate 20000 rbenv_version_prompt _omb_prompt_print_rbenv
_omb_util_defun_deprecate 20000 rvm_version_prompt _omb_prompt_print_rvm
_omb_util_defun_deprecate 20000 chruby_version_prompt _omb_prompt_print_chruby
_omb_util_defun_deprecate 20000 ruby_version_prompt _omb_prompt_print_ruby_env
_omb_deprecate_function 20000 rbfu_version_prompt _omb_prompt_print_rbfu
_omb_deprecate_function 20000 rbenv_version_prompt _omb_prompt_print_rbenv
_omb_deprecate_function 20000 rvm_version_prompt _omb_prompt_print_rvm
_omb_deprecate_function 20000 chruby_version_prompt _omb_prompt_print_chruby
_omb_deprecate_function 20000 ruby_version_prompt _omb_prompt_print_ruby_env
function _omb_prompt_get_virtualenv {
virtualenv=
@@ -484,10 +484,10 @@ _omb_util_defun_print _omb_prompt_{print,get}_python_version python_version
_omb_util_defun_print _omb_prompt_{print,get}_python_venv python_venv
_omb_util_defun_print _omb_prompt_{print,get}_python_env python_env
_omb_util_defun_deprecate 20000 virtualenv_prompt _omb_prompt_print_virtualenv
_omb_util_defun_deprecate 20000 condaenv_prompt _omb_prompt_print_condaenv
_omb_util_defun_deprecate 20000 py_interp_prompt _omb_prompt_print_python_version
_omb_util_defun_deprecate 20000 python_version_prompt _omb_prompt_print_python_env
_omb_deprecate_function 20000 virtualenv_prompt _omb_prompt_print_virtualenv
_omb_deprecate_function 20000 condaenv_prompt _omb_prompt_print_condaenv
_omb_deprecate_function 20000 py_interp_prompt _omb_prompt_print_python_version
_omb_deprecate_function 20000 python_version_prompt _omb_prompt_print_python_env
function git_user_info {
# support two or more initials, set by 'git pair' plugin
@@ -583,5 +583,5 @@ function aws_profile {
# Returns true if $1 is a shell function.
_omb_util_defun_deprecate 20000 fn_exists _omb_util_function_exists
_omb_util_defun_deprecate 20000 safe_append_prompt_command _omb_util_add_prompt_command
_omb_deprecate_function 20000 fn_exists _omb_util_function_exists
_omb_deprecate_function 20000 safe_append_prompt_command _omb_util_add_prompt_command