Update cli and relevant changes in mc
This commit is contained in:
Generated
+2
-2
@@ -63,8 +63,8 @@
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/minio-io/cli",
|
||||
"Comment": "1.2.0-106-g74f4efd",
|
||||
"Rev": "74f4efdae47555906336b1dcd30c4b40d4d0d6fa"
|
||||
"Comment": "1.2.0-107-ge085bd3",
|
||||
"Rev": "e085bd36977e5eddf82401db2f16d91fb1d65412"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/minio-io/minio/pkg/iodine",
|
||||
|
||||
+5
-6
@@ -6,7 +6,6 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"io/ioutil"
|
||||
"text/tabwriter"
|
||||
@@ -45,7 +44,7 @@ type App struct {
|
||||
// Execute this function if the proper command cannot be found
|
||||
CommandNotFound func(context *Context, command string)
|
||||
// Compilation date
|
||||
Compiled time.Time
|
||||
Compiled string
|
||||
// ExtraInfo pass additional info as a key value map
|
||||
ExtraInfo map[string]string
|
||||
// List of all authors who contributed
|
||||
@@ -59,17 +58,17 @@ type App struct {
|
||||
}
|
||||
|
||||
// mustCompileTime - determines the modification time of the current binary
|
||||
func mustCompileTime() time.Time {
|
||||
func mustCompileTime() string {
|
||||
path, err := exec.LookPath(os.Args[0])
|
||||
if err != nil {
|
||||
return time.Time{}
|
||||
return ""
|
||||
}
|
||||
|
||||
info, err := os.Stat(path)
|
||||
if err != nil {
|
||||
return time.Time{}
|
||||
return ""
|
||||
}
|
||||
return info.ModTime()
|
||||
return info.ModTime().String()
|
||||
}
|
||||
|
||||
// NewApp - Creates a new cli Application with some reasonable defaults for Name, Usage, Version and Action.
|
||||
|
||||
+7
-9
@@ -14,21 +14,19 @@ var AppHelpTemplate = `NAME:
|
||||
USAGE:
|
||||
{{.Name}} {{if .Flags}}[global flags] {{end}}command{{if .Flags}} [command flags]{{end}} [arguments...]
|
||||
|
||||
VERSION:
|
||||
{{.Version}}
|
||||
|
||||
BUILD:
|
||||
{{.Compiled}}
|
||||
{{range $key, $value := .ExtraInfo}}
|
||||
{{ $key }}:
|
||||
{{ $value }}
|
||||
{{ end }}
|
||||
COMMANDS:
|
||||
{{range .Commands}}{{join .Names ", "}}{{ "\t" }}{{.Usage}}
|
||||
{{end}}{{if .Flags}}
|
||||
GLOBAL FLAGS:
|
||||
{{range .Flags}}{{.}}
|
||||
{{end}}{{end}}
|
||||
VERSION:
|
||||
{{.Version}}
|
||||
{{if .Compiled}}
|
||||
BUILD:
|
||||
{{.Compiled}}{{end}}
|
||||
{{range $key, $value := .ExtraInfo}}
|
||||
{{$value}}{{end}}
|
||||
`
|
||||
|
||||
// The text template for the command help topic.
|
||||
|
||||
+6
-1
@@ -84,7 +84,12 @@ func runUpdateCmd(ctx *cli.Context) {
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Fatalln("Unable to parse update time:", results.LatestBuild)
|
||||
}
|
||||
if latest.After(ctx.App.Compiled) {
|
||||
current, err := time.Parse(time.RFC3339Nano, ctx.App.Compiled)
|
||||
if err != nil {
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Fatalln("Unable to parse update time:", current)
|
||||
}
|
||||
if latest.After(current) {
|
||||
printUpdateNotify("new", "old")
|
||||
}
|
||||
case "yes":
|
||||
|
||||
@@ -53,6 +53,18 @@ func checkConfig() {
|
||||
}
|
||||
}
|
||||
|
||||
// Build date
|
||||
var BuildDate string
|
||||
|
||||
// getBuildDate -
|
||||
func getBuildDate() string {
|
||||
if BuildDate == "" {
|
||||
return ""
|
||||
}
|
||||
t, _ := time.Parse(time.RFC3339Nano, BuildDate)
|
||||
return t.String()
|
||||
}
|
||||
|
||||
// Get os/arch/platform specific information.
|
||||
// Returns a map of current os/arch/platform/memstats
|
||||
func getSystemData() map[string]string {
|
||||
@@ -82,15 +94,12 @@ func getSystemData() map[string]string {
|
||||
// Version is based on MD5SUM of its binary
|
||||
var Version = mustHashBinarySelf()
|
||||
|
||||
// Build date
|
||||
var BuildDate string
|
||||
|
||||
func main() {
|
||||
app := cli.NewApp()
|
||||
app.Usage = "Minio Client for object storage and filesystems"
|
||||
app.Version = Version
|
||||
app.Commands = commands
|
||||
app.Compiled, _ = time.Parse(time.RFC3339Nano, BuildDate)
|
||||
app.Compiled = getBuildDate()
|
||||
app.Flags = flags
|
||||
app.Author = "Minio.io"
|
||||
app.Before = func(ctx *cli.Context) error {
|
||||
|
||||
Reference in New Issue
Block a user