add a fix

This commit is contained in:
Lynn Cyrin 2019-12-24 08:53:59 -08:00
parent b62c6419cb
commit 1651eec7b8
No known key found for this signature in database
GPG Key ID: 9E60BEE0555C367B
2 changed files with 7 additions and 3 deletions

View File

@ -33,6 +33,10 @@ func NewContext(app *App, set *flag.FlagSet, parentCtx *Context) *Context {
if parentCtx != nil {
c.Context = parentCtx.Context
c.shellComplete = parentCtx.shellComplete
if parentCtx.flagSet == nil {
parentCtx.flagSet = &flag.FlagSet{}
}
}
c.Command = &Command{}

View File

@ -380,8 +380,8 @@ func TestContextAttributeAccessing(t *testing.T) {
for _, test := range tdata {
t.Run(test.testCase, func(t *testing.T) {
// setup
set := flag.NewFlagSet("test", 0)
set.Bool(test.setBoolInput, false, "doc")
set := flag.NewFlagSet("some-flag-set-name", 0)
set.Bool(test.setBoolInput, false, "usage documentation")
ctx := NewContext(nil, set, test.newContextInput)
// logic under test
@ -389,7 +389,7 @@ func TestContextAttributeAccessing(t *testing.T) {
// assertions
if value != false {
t.Errorf("expected test.value to be false, but it was not")
t.Errorf("expected \"value\" to be false, but it was not")
}
})
}