export_test.go 735 B

1234567891011121314151617181920212223242526272829
  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. package pflag
  5. import (
  6. "io/ioutil"
  7. "os"
  8. )
  9. // Additional routines compiled into the package only during testing.
  10. // ResetForTesting clears all flag state and sets the usage function as directed.
  11. // After calling ResetForTesting, parse errors in flag handling will not
  12. // exit the program.
  13. func ResetForTesting(usage func()) {
  14. CommandLine = &FlagSet{
  15. name: os.Args[0],
  16. errorHandling: ContinueOnError,
  17. output: ioutil.Discard,
  18. }
  19. Usage = usage
  20. }
  21. // GetCommandLine returns the default FlagSet.
  22. func GetCommandLine() *FlagSet {
  23. return CommandLine
  24. }