Add --init-completion flag to print completion code
This flag takes as input 'bash' or 'zsh' and generates the completion code for the specified shell.
This commit is contained in:
6
app.go
6
app.go
@@ -138,6 +138,7 @@ func (a *App) Setup() {
|
||||
|
||||
if a.EnableBashCompletion {
|
||||
a.appendFlag(BashCompletionFlag)
|
||||
a.appendFlag(InitCompletionFlag)
|
||||
}
|
||||
|
||||
if !a.HideVersion {
|
||||
@@ -176,6 +177,11 @@ func (a *App) Run(arguments []string) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
var done bool
|
||||
if done, err = checkInitCompletion(context); done {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
if a.OnUsageError != nil {
|
||||
err := a.OnUsageError(context, err, false)
|
||||
|
Reference in New Issue
Block a user