From 2b66100c47a77a1294a525f5337734ebaf757e46 Mon Sep 17 00:00:00 2001 From: Noah Gorny Date: Sat, 16 Jan 2021 22:57:04 +0200 Subject: [PATCH] helpers: Add _completion_exists helper --- lib/helpers.bash | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/helpers.bash b/lib/helpers.bash index 436fc59e..b89bad3d 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -37,6 +37,17 @@ function _binary_exists () type -P "$1" &> /dev/null || (_log_warning "$msg" && return 1) ; } +function _completion_exists () +{ + _about 'checks for existence of a completion' + _param '1: command to check' + _param '2: (optional) log message to include when completion is found' + _example '$ _completion_exists gh && echo exists' + _group 'lib' + local msg="${2:-Completion for '$1' already exists!}" + complete -p "$1" &> /dev/null && _log_warning "$msg" ; +} + function _make_reload_alias() { echo "source \${BASH_IT}/scripts/reloader.bash ${1} ${2}" }