From df28e7154bbab76436bc59e5dc67fb6d6824fc62 Mon Sep 17 00:00:00 2001 From: Alex Flint Date: Wed, 8 Feb 2023 09:49:03 -0500 Subject: clean up customizable stdout, stderr, and exit in parser config --- example_test.go | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) (limited to 'example_test.go') diff --git a/example_test.go b/example_test.go index fd64777..5272393 100644 --- a/example_test.go +++ b/example_test.go @@ -162,8 +162,7 @@ func Example_helpText() { } // This is only necessary when running inside golang's runnable example harness - osExit = func(int) {} - stdout = os.Stdout + mustParseExit = func(int) {} MustParse(&args) @@ -195,8 +194,7 @@ func Example_helpPlaceholder() { } // This is only necessary when running inside golang's runnable example harness - osExit = func(int) {} - stdout = os.Stdout + mustParseExit = func(int) {} MustParse(&args) @@ -236,8 +234,7 @@ func Example_helpTextWithSubcommand() { } // This is only necessary when running inside golang's runnable example harness - osExit = func(int) {} - stdout = os.Stdout + mustParseExit = func(int) {} MustParse(&args) @@ -274,8 +271,7 @@ func Example_helpTextWhenUsingSubcommand() { } // This is only necessary when running inside golang's runnable example harness - osExit = func(int) {} - stdout = os.Stdout + mustParseExit = func(int) {} MustParse(&args) @@ -311,10 +307,9 @@ func Example_writeHelpForSubcommand() { } // This is only necessary when running inside golang's runnable example harness - osExit = func(int) {} - stdout = os.Stdout + exit := func(int) {} - p, err := NewParser(Config{}, &args) + p, err := NewParser(Config{Exit: exit}, &args) if err != nil { fmt.Println(err) os.Exit(1) @@ -360,10 +355,9 @@ func Example_writeHelpForSubcommandNested() { } // This is only necessary when running inside golang's runnable example harness - osExit = func(int) {} - stdout = os.Stdout + exit := func(int) {} - p, err := NewParser(Config{}, &args) + p, err := NewParser(Config{Exit: exit}, &args) if err != nil { fmt.Println(err) os.Exit(1) @@ -397,8 +391,7 @@ func Example_errorText() { } // This is only necessary when running inside golang's runnable example harness - osExit = func(int) {} - stderr = os.Stdout + mustParseExit = func(int) {} MustParse(&args) @@ -421,8 +414,7 @@ func Example_errorTextForSubcommand() { } // This is only necessary when running inside golang's runnable example harness - osExit = func(int) {} - stderr = os.Stdout + mustParseExit = func(int) {} MustParse(&args) @@ -457,8 +449,7 @@ func Example_subcommand() { } // This is only necessary when running inside golang's runnable example harness - osExit = func(int) {} - stderr = os.Stdout + mustParseExit = func(int) {} MustParse(&args) -- cgit v1.2.3