Bring in changes from minio-io/cli

This commit is contained in:
root
2015-04-26 15:34:05 -07:00
parent a3af3514ca
commit c2d8053787
10 changed files with 36 additions and 26 deletions
+11 -6
View File
@@ -4,6 +4,7 @@ import (
"fmt"
"io"
"os"
"os/exec"
"strings"
"time"
@@ -57,12 +58,16 @@ type App struct {
Writer io.Writer
}
// Tries to find out when this binary was compiled.
// Returns the current time if it fails to find it.
func compileTime() time.Time {
info, err := os.Stat(os.Args[0])
// mustCompileTime - determines the modification time of the current binary
func mustCompileTime() time.Time {
path, err := exec.LookPath(os.Args[0])
if err != nil {
return time.Now()
return time.Time{}
}
info, err := os.Stat(path)
if err != nil {
return time.Time{}
}
return info.ModTime()
}
@@ -75,7 +80,7 @@ func NewApp() *App {
Version: "0.0.0",
BashComplete: DefaultAppComplete,
Action: helpCommand.Action,
Compiled: compileTime(),
Compiled: mustCompileTime(),
Writer: os.Stdout,
}
}