mirror of https://github.com/perkeep/perkeep.git
cmdmain: guard ExtraFlagRegistration with a Once
Change-Id: Id54111dc21eeb61b02721117123b956fcc3b47fd
This commit is contained in:
parent
a41cc2bab1
commit
f99eaf5e36
|
@ -26,6 +26,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"camlistore.org/pkg/buildinfo"
|
"camlistore.org/pkg/buildinfo"
|
||||||
)
|
)
|
||||||
|
@ -212,10 +213,14 @@ func help(mode string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// registerFlagOnce guards ExtraFlagRegistration. Tests may invoke
|
||||||
|
// Main multiple times, but duplicate flag registration is fatal.
|
||||||
|
var registerFlagOnce sync.Once
|
||||||
|
|
||||||
// Main is meant to be the core of a command that has
|
// Main is meant to be the core of a command that has
|
||||||
// subcommands (modes), such as camput or camtool.
|
// subcommands (modes), such as camput or camtool.
|
||||||
func Main() {
|
func Main() {
|
||||||
ExtraFlagRegistration()
|
registerFlagOnce.Do(ExtraFlagRegistration)
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
args := flag.Args()
|
args := flag.Args()
|
||||||
if *FlagVersion {
|
if *FlagVersion {
|
||||||
|
|
Loading…
Reference in New Issue