Skip to content

Commit 363b9fc

Browse files
committed
feat(golangci-lint): add fallback 3rd party completion loader
1 parent f402bf0 commit 363b9fc

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

completions/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ bashcomp_DATA = 2to3 \
137137
gnokii \
138138
gnome-mplayer \
139139
gnome-screenshot \
140+
_golangci-lint \
140141
gpasswd \
141142
gpg \
142143
gpg2 \

completions/_golangci-lint

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# 3rd party completion loader for commands emitting -*- shell-script -*-
2+
# their completion using "$cmd completion bash".
3+
# For example, many Go programs using https://github.com/spf13/cobra do.
4+
#
5+
# This serves as a fallback in case the completion is not installed otherwise.
6+
7+
# shellcheck disable=SC2168 # "local" is ok, assume sourced by __load_completion
8+
local _comp__load_3rdparty_reset_shopt=$(shopt -po posix)
9+
set +o posix
10+
11+
. <("$1" completion bash 2>/dev/null)
12+
13+
$_comp__load_3rdparty_reset_shopt
14+
15+
{
16+
complete -p "$1" || complete -p "${1##*/}"
17+
} &>/dev/null
18+
19+
# ex: filetype=sh

test/fallback/completions/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ EXTRA_DIST = \
66
dmesg \
77
eject \
88
gh \
9+
golangci-lint \
910
hexdump \
1011
hwclock \
1112
ionice \
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../completions/_golangci-lint

0 commit comments

Comments
 (0)