File tree 2 files changed +16
-1
lines changed
2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -827,7 +827,9 @@ func (c *Context) Run(binds ...any) (err error) {
827
827
if method .IsValid () {
828
828
node = selected
829
829
}
830
- } else {
830
+ }
831
+
832
+ if node == nil {
831
833
return fmt .Errorf ("no command selected" )
832
834
}
833
835
}
Original file line number Diff line number Diff line change @@ -2495,3 +2495,16 @@ func TestPrefixXorIssue343(t *testing.T) {
2495
2495
_ , err = kctx .Parse ([]string {"--source-password-file=foo" , "--source-password=bar" })
2496
2496
assert .Error (t , err )
2497
2497
}
2498
+
2499
+ func TestIssue483EmptyRootNodeNoRun (t * testing.T ) {
2500
+ var emptyCLI struct {}
2501
+ parser , err := kong .New (& emptyCLI )
2502
+ assert .NoError (t , err )
2503
+
2504
+ kctx , err := parser .Parse ([]string {})
2505
+ assert .NoError (t , err )
2506
+
2507
+ err = kctx .Run ()
2508
+ assert .Error (t , err )
2509
+ assert .Contains (t , err .Error (), "no command selected" )
2510
+ }
You can’t perform that action at this time.
0 commit comments