cmdmain, camput: PreExit should always run, not just in verbose mode

Change-Id: I6001a3474071a00f0ab56b031ac8c5504e5e9da5
This commit is contained in:
Brad Fitzpatrick 2014-02-27 20:47:15 -08:00
parent a73715c92a
commit 593e0f0f81
2 changed files with 8 additions and 8 deletions

View File

@ -64,12 +64,14 @@ func init() {
if up := uploader; up != nil {
up.Close()
stats := up.Stats()
if *cmdmain.FlagVerbose {
log.Printf("Client stats: %s", stats.String())
if up.transport != nil {
log.Printf(" #HTTP reqs: %d", up.transport.Requests())
}
}
}
}
}
func getUploader() *Uploader {

View File

@ -41,8 +41,8 @@ var (
// ExtraFlagRegistration allows to add more flags from
// other packages (with AddFlags) when Main starts.
ExtraFlagRegistration = func() {}
// PreExit is meant to dump additional stats and other
// verbiage before Main terminates.
// PreExit runs after the subcommand, but before Main terminates
// with either success or the error from the subcommand.
PreExit = func() {}
// ExitWithFailure determines whether the command exits
// with a non-zero exit status.
@ -278,9 +278,7 @@ func Main() {
}
Exit(1)
}
if *FlagVerbose {
PreExit()
}
if err != nil {
if !ExitWithFailure {
// because it was already logged if ExitWithFailure