Refactoring names from bash to shell
The refactoring is required since completion is also supported for zsh shell. Refactoring details: - flag generate-bash-completion -> generate-completion - var EnableBashCompletion -> EnableShellCompletion - var BashComplete -> ShellComplete - var BashCompletionFlag -> GenerateCompletionFlag - type BashCompleteFunc -> ShellCompleteFunc
This commit is contained in:
14
help.go
14
help.go
@@ -182,16 +182,16 @@ func printVersion(c *Context) {
|
||||
// ShowCompletions prints the lists of commands within a given context
|
||||
func ShowCompletions(c *Context) {
|
||||
a := c.App
|
||||
if a != nil && a.BashComplete != nil {
|
||||
a.BashComplete(c)
|
||||
if a != nil && a.ShellComplete != nil {
|
||||
a.ShellComplete(c)
|
||||
}
|
||||
}
|
||||
|
||||
// ShowCommandCompletions prints the custom completions for a given command
|
||||
func ShowCommandCompletions(ctx *Context, command string) {
|
||||
c := ctx.App.Command(command)
|
||||
if c != nil && c.BashComplete != nil {
|
||||
c.BashComplete(ctx)
|
||||
if c != nil && c.ShellComplete != nil {
|
||||
c.ShellComplete(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ func checkSubcommandHelp(c *Context) bool {
|
||||
}
|
||||
|
||||
func checkCompletions(c *Context) bool {
|
||||
if c.Bool(BashCompletionFlag.Name) && c.App.EnableBashCompletion {
|
||||
if c.Bool(GenerateCompletionFlag.Name) && c.App.EnableShellCompletion {
|
||||
ShowCompletions(c)
|
||||
return true
|
||||
}
|
||||
@@ -279,7 +279,7 @@ func checkCompletions(c *Context) bool {
|
||||
}
|
||||
|
||||
func checkCommandCompletions(c *Context, name string) bool {
|
||||
if c.Bool(BashCompletionFlag.Name) && c.App.EnableBashCompletion {
|
||||
if c.Bool(GenerateCompletionFlag.Name) && c.App.EnableShellCompletion {
|
||||
ShowCommandCompletions(c, name)
|
||||
return true
|
||||
}
|
||||
@@ -310,7 +310,7 @@ func bashCompletionCode(progName string) string {
|
||||
local cur opts base;
|
||||
COMPREPLY=();
|
||||
cur="${COMP_WORDS[COMP_CWORD]}";
|
||||
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion );
|
||||
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-completion );
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) );
|
||||
return 0;
|
||||
};
|
||||
|
Reference in New Issue
Block a user