Skip to content

Commit

Permalink
zsh: usage support
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Nov 27, 2022
1 parent 93ca86c commit d535ba4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion example/cmd/_test/zsh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ function _example_completion {
fi

export ZLS_COLOURS="${lines[1]}"
[[ ! "${lines[2]}" == "NONE" ]] && _message -r "${lines[2]}"

# shellcheck disable=SC2034,2206
lines=(${lines[@]:1})
lines=(${lines[@]:2})
# shellcheck disable=SC2034,2206
local vals=(${lines%$'\t'*})
# shellcheck disable=SC2034,2206
Expand Down
6 changes: 5 additions & 1 deletion internal/shell/zsh/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ func ActionRawValues(currentWord string, usage string, nospace common.SuffixMatc
if len(zstyles) > 1000 { // TODO disable styling for large amount of values (bad performance)
zstyles = make([]string, 0)
}
return fmt.Sprintf(":%v\n%v", strings.Join(zstyles, ":"), strings.Join(vals, "\n"))

if usage == "" {
usage = "NONE" // TODO fix empty line issue in script
}
return fmt.Sprintf(":%v\n%v\n%v", strings.Join(zstyles, ":"), usage, strings.Join(vals, "\n"))
}

var zstyleQuoter = strings.NewReplacer(
Expand Down
3 changes: 2 additions & 1 deletion internal/shell/zsh/snippet.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ function _%v_completion {
fi
export ZLS_COLOURS="${lines[1]}"
[[ ! "${lines[2]}" == "NONE" ]] && _message -r "${lines[2]}"
# shellcheck disable=SC2034,2206
lines=(${lines[@]:1})
lines=(${lines[@]:2})
# shellcheck disable=SC2034,2206
local vals=(${lines%%$'\t'*})
# shellcheck disable=SC2034,2206
Expand Down

0 comments on commit d535ba4

Please sign in to comment.