Get delegate based completion working for bash
This commit is contained in:
parent
1dce092ac0
commit
08c697e99a
@ -13,6 +13,13 @@ var _ = fmt.Print
|
|||||||
|
|
||||||
func bash_output_serializer(completions []*Completions, shell_state map[string]string) ([]byte, error) {
|
func bash_output_serializer(completions []*Completions, shell_state map[string]string) ([]byte, error) {
|
||||||
output := strings.Builder{}
|
output := strings.Builder{}
|
||||||
|
f := func(format string, args ...interface{}) { fmt.Fprintf(&output, format, args...) }
|
||||||
|
n := completions[0].Delegate.NumToRemove
|
||||||
|
if n > 0 {
|
||||||
|
n--
|
||||||
|
f("COMP_WORDS[%d]=%s\n", n, utils.QuoteStringForSH(completions[0].Delegate.Command))
|
||||||
|
f("_command_offset %d\n", n)
|
||||||
|
} else {
|
||||||
for _, mg := range completions[0].Groups {
|
for _, mg := range completions[0].Groups {
|
||||||
mg.remove_common_prefix()
|
mg.remove_common_prefix()
|
||||||
for _, m := range mg.Matches {
|
for _, m := range mg.Matches {
|
||||||
@ -20,9 +27,11 @@ func bash_output_serializer(completions []*Completions, shell_state map[string]s
|
|||||||
if !mg.NoTrailingSpace {
|
if !mg.NoTrailingSpace {
|
||||||
w += " "
|
w += " "
|
||||||
}
|
}
|
||||||
fmt.Fprintln(&output, "COMPREPLY+=("+utils.QuoteStringForSH(w)+")")
|
f("COMPREPLY+=(%s)\n", utils.QuoteStringForSH(w))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// debugf("%#v", output.String())
|
||||||
return []byte(output.String()), nil
|
return []byte(output.String()), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user