tea: add shell completion scripts

This commit is contained in:
Marcin Puc 2022-08-10 22:43:15 +02:00 committed by classabbyamp
parent b1d7277340
commit 0632430a6a
2 changed files with 58 additions and 1 deletions

View File

@ -0,0 +1,49 @@
diff --git a/cmd/autocomplete.go b/cmd/autocomplete.go
index 4c0ab1a..7e9b0a4 100644
--- a/cmd/autocomplete.go
+++ b/cmd/autocomplete.go
@@ -122,6 +122,9 @@ func writeFishAutoCompleteFile(ctx *cli.Context) error {
return err
}
+ _, status := io.WriteString(os.Stdout, script)
+ return status
+
localPath, err := xdg.ConfigFile("fish/conf.d/tea_completion.fish")
if err != nil {
return err
diff --git a/contrib/autocomplete.sh b/contrib/autocomplete.sh
index f0f6241..17f7ce1 100644
--- a/contrib/autocomplete.sh
+++ b/contrib/autocomplete.sh
@@ -1,7 +1,5 @@
#! /bin/bash
-: ${PROG:=$(basename ${BASH_SOURCE})}
-
_cli_bash_autocomplete() {
if [[ "${COMP_WORDS[0]}" != "source" ]]; then
local cur opts base
@@ -17,5 +15,4 @@ _cli_bash_autocomplete() {
fi
}
-complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete $PROG
-unset PROG
+complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete tea
diff --git a/contrib/autocomplete.zsh b/contrib/autocomplete.zsh
index cf39c88..f718c0a 100644
--- a/contrib/autocomplete.zsh
+++ b/contrib/autocomplete.zsh
@@ -1,4 +1,4 @@
-#compdef $PROG
+#compdef tea
_cli_zsh_autocomplete() {
@@ -20,4 +20,4 @@ _cli_zsh_autocomplete() {
return
}
-compdef _cli_zsh_autocomplete $PROG
+compdef _cli_zsh_autocomplete tea

View File

@ -1,9 +1,10 @@
# Template file for 'tea'
pkgname=tea
version=0.8.0
revision=1
revision=2
wrksrc=$pkgname
build_style=go
build_helper=qemu
go_import_path=code.gitea.io/tea
depends="git"
short_desc="Command line tool to interact with Gitea"
@ -15,5 +16,12 @@ distfiles="https://gitea.com/gitea/tea/archive/v${version}.tar.gz"
checksum=6c73c0a7b66cdfd1e5a302257d54df06a3a41eb9bdbfeb547966db431ae23b23
post_install() {
vcompletion contrib/autocomplete.sh bash
vcompletion contrib/autocomplete.zsh zsh
binary=$(find $GOPATH/bin -name $pkgname)
vtargetrun ${binary} shellcompletion fish > tea.fish
vcompletion tea.fish fish
vlicense LICENSE
}