Implement a robust Context.Run().

This helps when composing large applications from separate command
structs.
This commit is contained in:
Alec Thomas
2018-06-21 21:50:30 +10:00
parent e4f37b5d1a
commit a2ec050947
16 changed files with 727 additions and 279 deletions
+7 -5
View File
@@ -1,10 +1,12 @@
package kong
package kong_test
import (
"bytes"
"testing"
"github.com/stretchr/testify/require"
"github.com/alecthomas/kong"
)
func TestHelp(t *testing.T) {
@@ -37,10 +39,10 @@ func TestHelp(t *testing.T) {
w := bytes.NewBuffer(nil)
exited := false
app := mustNew(t, &cli,
Name("test-app"),
Description("A test app."),
Writers(w, w),
Exit(func(int) {
kong.Name("test-app"),
kong.Description("A test app."),
kong.Writers(w, w),
kong.Exit(func(int) {
exited = true
panic(true) // Panic to fake "exit".
}),