Allow hiding of help flag without hiding help subcommand

By utilizing struct zero value
This commit is contained in:
jszwedko
2014-12-01 23:20:21 -05:00
parent 9908e96513
commit 780f839a02
4 changed files with 26 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
package cli_test
import (
"flag"
"fmt"
"os"
"testing"
@@ -331,6 +332,22 @@ func TestApp_BeforeFunc(t *testing.T) {
}
func TestAppNoHelpFlag(t *testing.T) {
oldFlag := cli.HelpFlag
defer func() {
cli.HelpFlag = oldFlag
}()
cli.HelpFlag = cli.BoolFlag{}
app := cli.NewApp()
err := app.Run([]string{"test", "-h"})
if err != flag.ErrHelp {
t.Errorf("expected error about missing help flag, but got: %s (%T)", err, err)
}
}
func TestAppHelpPrinter(t *testing.T) {
oldPrinter := cli.HelpPrinter
defer func() {