Skip to content

Commit

Permalink
feat(sops): add 3rd party fallback completion loader
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Jun 7, 2024
1 parent 8304d33 commit bbf9088
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions completions/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ bashcomp_DATA = 2to3 \
smartctl \
smbclient \
snownews \
_sops \
sqlite3 \
ss \
ssh \
Expand Down
24 changes: 24 additions & 0 deletions completions/_sops
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 3rd party completion loader for commands using -*- shell-script -*-
# version 1 of the https://cli.urfave.org library.
#
# This serves as a fallback in case the completion is not installed otherwise.

# https://github.com/urfave/cli/blob/v1-maint/docs/v1/manual.md#bash-completion
# https://github.com/urfave/cli/blob/v1-maint/autocomplete/bash_autocomplete
_comp_cmd__urfave_cli_v1()
{
local cur prev words cword comp_args
_comp_initialize -- "$@" || return

local compcmd=("${words[@]:0:cword}")
if [[ $cur == -* ]]; then
compcmd+=("$cur")
fi
compcmd+=(--generate-bash-completion)

_comp_compgen_split -- "$("${compcmd[@]}" 2>/dev/null)"
} &&
complete -o bashdefault -o default -o nospace \
-F _comp_cmd__urfave_cli_v1 "$1"

# ex: filetype=sh
1 change: 1 addition & 0 deletions test/fallback/completions/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ EXTRA_DIST = \
runuser \
rustup \
slackpkg \
sops \
su \
svn \
svnadmin \
Expand Down
1 change: 1 addition & 0 deletions test/fallback/completions/sops

0 comments on commit bbf9088

Please sign in to comment.