add a fix
This commit is contained in:
parent
b62c6419cb
commit
1651eec7b8
@ -33,6 +33,10 @@ func NewContext(app *App, set *flag.FlagSet, parentCtx *Context) *Context {
|
|||||||
if parentCtx != nil {
|
if parentCtx != nil {
|
||||||
c.Context = parentCtx.Context
|
c.Context = parentCtx.Context
|
||||||
c.shellComplete = parentCtx.shellComplete
|
c.shellComplete = parentCtx.shellComplete
|
||||||
|
|
||||||
|
if parentCtx.flagSet == nil {
|
||||||
|
parentCtx.flagSet = &flag.FlagSet{}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Command = &Command{}
|
c.Command = &Command{}
|
||||||
|
@ -380,8 +380,8 @@ func TestContextAttributeAccessing(t *testing.T) {
|
|||||||
for _, test := range tdata {
|
for _, test := range tdata {
|
||||||
t.Run(test.testCase, func(t *testing.T) {
|
t.Run(test.testCase, func(t *testing.T) {
|
||||||
// setup
|
// setup
|
||||||
set := flag.NewFlagSet("test", 0)
|
set := flag.NewFlagSet("some-flag-set-name", 0)
|
||||||
set.Bool(test.setBoolInput, false, "doc")
|
set.Bool(test.setBoolInput, false, "usage documentation")
|
||||||
ctx := NewContext(nil, set, test.newContextInput)
|
ctx := NewContext(nil, set, test.newContextInput)
|
||||||
|
|
||||||
// logic under test
|
// logic under test
|
||||||
@ -389,7 +389,7 @@ func TestContextAttributeAccessing(t *testing.T) {
|
|||||||
|
|
||||||
// assertions
|
// assertions
|
||||||
if value != false {
|
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")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user