review: fix tests
Change-Id: I7eca48ab8f12c89da4a4a7eb8f5aa21b02b1d90a
Reviewed-on: https://go-review.googlesource.com/1502
Reviewed-by: Andrew Gerrand <adg@golang.org>
diff --git a/git-review/review.go b/git-review/review.go
index ec2627d..6a6672d 100644
--- a/git-review/review.go
+++ b/git-review/review.go
@@ -26,13 +26,18 @@
)
var (
- flags = flag.NewFlagSet("", flag.ExitOnError)
+ flags *flag.FlagSet
verbose = new(count) // installed as -v below
- noRun = flags.Bool("n", false, "print but do not run commands")
+ noRun = new(bool)
)
-func init() {
+func initFlags() {
+ flags = flag.NewFlagSet("", flag.ExitOnError)
+ flags.Usage = func() {
+ fmt.Fprintf(os.Stderr, usage, os.Args[0], os.Args[0])
+ }
flags.Var(verbose, "v", "report git commands")
+ flags.BoolVar(noRun, "n", false, "print but do not run commands")
}
const globalFlags = "[-n] [-v]"
@@ -41,12 +46,6 @@
Type "%s help" for more information.
`
-func init() {
- flags.Usage = func() {
- fmt.Fprintf(os.Stderr, usage, os.Args[0], os.Args[0])
- }
-}
-
const help = `Usage: %s <command> ` + globalFlags + `
The review command is a wrapper for the git command that provides a simple
@@ -91,6 +90,8 @@
`
func main() {
+ initFlags()
+
if len(os.Args) < 2 {
flags.Usage()
if dieTrap != nil {