Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ archives:
files:
- LICENSE
- README.md
- completions/*
rlcp: true


Expand All @@ -59,6 +60,10 @@ brews:
homepage: "https://echo.umputun.com"
description: "Responds with json-formatted echo of the incoming request and with a predefined message."
license: "MIT"
extra_install: |
bash_completion.install "completions/echo-http.bash" => "echo-http"
zsh_completion.install "completions/echo-http.zsh" => "_echo-http"
fish_completion.install "completions/echo-http.fish" => "echo-http.fish"

nfpms:
- id: echo-http
Expand All @@ -76,3 +81,10 @@ nfpms:
bindir: /usr/bin
epoch: 1
release: 1
contents:
- src: completions/echo-http.bash
dst: /usr/share/bash-completion/completions/echo-http
- src: completions/echo-http.zsh
dst: /usr/share/zsh/vendor-completions/_echo-http
- src: completions/echo-http.fish
dst: /usr/share/fish/vendor_completions.d/echo-http.fish
7 changes: 7 additions & 0 deletions completions/echo-http.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# bash completion for echo-http (generated via go-flags)
_echo_http() {
local args=("${COMP_WORDS[@]:1:$COMP_CWORD}")
mapfile -t COMPREPLY < <(GO_FLAGS_COMPLETION=1 "${COMP_WORDS[0]}" "${args[@]}" 2>/dev/null)
return 0
}
complete -o default -F _echo_http echo-http
2 changes: 2 additions & 0 deletions completions/echo-http.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# fish completion for echo-http (generated via go-flags)
complete -c echo-http -a '(GO_FLAGS_COMPLETION=verbose echo-http (commandline -cop) 2>/dev/null | string replace -r "\\s+# " "\t")'
28 changes: 28 additions & 0 deletions completions/echo-http.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#compdef echo-http

# zsh completion for echo-http (generated via go-flags)
_echo_http() {
local -a lines
lines=(${(f)"$(GO_FLAGS_COMPLETION=verbose "${words[1]}" "${(@)words[2,$CURRENT]}" 2>/dev/null)"})
if (( ${#lines} )); then
local -a descr
local line item desc
for line in "${lines[@]}"; do
if [[ "$line" = *' # '* ]]; then
item="${line%% *}"
desc="${line#* \# }"
descr+=("${item//:/\\:}:${desc}")
else
item="${line%% *}"
[[ -z "$item" ]] && item="$line"
[[ "$item" = *" "* ]] && continue
descr+=("${item//:/\\:}")
fi
done
_describe 'command' descr
else
_files
fi
}

_echo_http "$@"
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ var opts struct {
var revision = "local"

func main() {
fmt.Printf("echo-http %s\n", revision)
if os.Getenv("GO_FLAGS_COMPLETION") == "" {
fmt.Printf("echo-http %s\n", revision)
}

p := flags.NewParser(&opts, flags.PrintErrors|flags.PassDoubleDash|flags.HelpFlag)
p.SubcommandsOptional = true
Expand Down
Loading