...

Source file src/github.com/spf13/pflag/export_test.go

Documentation: github.com/spf13/pflag

     1  // Copyright 2010 The Go Authors.  All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package pflag
     6  
     7  import (
     8  	"io/ioutil"
     9  	"os"
    10  )
    11  
    12  // Additional routines compiled into the package only during testing.
    13  
    14  // ResetForTesting clears all flag state and sets the usage function as directed.
    15  // After calling ResetForTesting, parse errors in flag handling will not
    16  // exit the program.
    17  func ResetForTesting(usage func()) {
    18  	CommandLine = &FlagSet{
    19  		name:          os.Args[0],
    20  		errorHandling: ContinueOnError,
    21  		output:        ioutil.Discard,
    22  	}
    23  	Usage = usage
    24  }
    25  
    26  // GetCommandLine returns the default FlagSet.
    27  func GetCommandLine() *FlagSet {
    28  	return CommandLine
    29  }
    30  

View as plain text