make shell autocomplete more robust

This commit is contained in:
Joshua Rubin
2016-11-04 14:56:28 -06:00
parent d86a009f5e
commit ea3df26e64
4 changed files with 62 additions and 37 deletions

View File

@@ -15,6 +15,7 @@ import (
type Context struct {
App *App
Command Command
complete bool
flagSet *flag.FlagSet
setFlags map[string]bool
parentContext *Context
@@ -22,7 +23,13 @@ type Context struct {
// NewContext creates a new context. For use in when invoking an App or Command action.
func NewContext(app *App, set *flag.FlagSet, parentCtx *Context) *Context {
return &Context{App: app, flagSet: set, parentContext: parentCtx}
c := &Context{App: app, flagSet: set, parentContext: parentCtx}
if parentCtx != nil {
c.complete = parentCtx.complete
}
return c
}
// NumFlags returns the number of flags set