Do print-and-exit flags before logging
This commit is contained in:
parent
34c33c724a
commit
428169b87e
|
|
@ -325,17 +325,7 @@ func main() {
|
|||
|
||||
pflag.Parse()
|
||||
|
||||
// Needs to happen very early for errors to be written to a file.
|
||||
log := func() *logging.Logger {
|
||||
if strings.HasPrefix(*flErrorFile, ".") {
|
||||
fmt.Fprintf(os.Stderr, "ERROR: --error-file may not start with '.'")
|
||||
os.Exit(1)
|
||||
}
|
||||
dir, file := filepath.Split(makeAbsPath(*flErrorFile, *flRoot))
|
||||
return logging.New(dir, file, *flVerbose)
|
||||
}()
|
||||
cmdRunner := cmd.NewRunner(log)
|
||||
|
||||
// Handle print-and-exit cases.
|
||||
if *flVersion {
|
||||
fmt.Println(version.VERSION)
|
||||
os.Exit(0)
|
||||
|
|
@ -350,6 +340,17 @@ func main() {
|
|||
os.Exit(0)
|
||||
}
|
||||
|
||||
// Init logging very early, so most errors can be written to a file.
|
||||
log := func() *logging.Logger {
|
||||
if strings.HasPrefix(*flErrorFile, ".") {
|
||||
fmt.Fprintf(os.Stderr, "ERROR: --error-file may not start with '.'")
|
||||
os.Exit(1)
|
||||
}
|
||||
dir, file := filepath.Split(makeAbsPath(*flErrorFile, *flRoot))
|
||||
return logging.New(dir, file, *flVerbose)
|
||||
}()
|
||||
cmdRunner := cmd.NewRunner(log)
|
||||
|
||||
if *flRepo == "" {
|
||||
handleConfigError(log, true, "ERROR: --repo must be specified")
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue