From dae79df3168ffb88dd40adcad1bc96bf44a382a9 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 11 Jun 2015 14:36:35 -0700 Subject: [PATCH] Add errInvalidTheme and .Before should reply back to cli as error --- Godeps/Godeps.json | 4 +-- .../src/github.com/minio/cli/app.go | 1 - errors.go | 26 ++++++------------- main.go | 14 +++++----- 4 files changed, 17 insertions(+), 28 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 7a67f1cd..e6bd0375 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -23,8 +23,8 @@ }, { "ImportPath": "github.com/minio/cli", - "Comment": "1.2.0-111-g432a101", - "Rev": "432a1019ded42d1b34fb5f1aad60fb609245d5a1" + "Comment": "1.2.0-112-g823349c", + "Rev": "823349ce91e76834a4af0119d5bbc58fd4d2c6b0" }, { "ImportPath": "github.com/minio/minio-go", diff --git a/Godeps/_workspace/src/github.com/minio/cli/app.go b/Godeps/_workspace/src/github.com/minio/cli/app.go index 57f1a887..acde02bb 100644 --- a/Godeps/_workspace/src/github.com/minio/cli/app.go +++ b/Godeps/_workspace/src/github.com/minio/cli/app.go @@ -198,7 +198,6 @@ func (a *App) Run(arguments []string) (err error) { // RunAndExitOnError - Another entry point to the cli app, takes care of passing arguments and error handling func (a *App) RunAndExitOnError() { if err := a.Run(os.Args); err != nil { - fmt.Fprintln(os.Stderr, err) os.Exit(1) } } diff --git a/errors.go b/errors.go index 2a1c7503..6457c6e8 100644 --- a/errors.go +++ b/errors.go @@ -91,24 +91,6 @@ func (e errAliasExists) Error() string { return "Alias name: " + e.name + " exists" } -/* -type errIsNotBucket struct { - URL string -} - -func (e errIsNotBucket) Error() string { - return "Not a bucket " + e.URL -} - -// errInvalidAuthKeys - invalid authorization keys -type errInvalidAuthKeys struct { -} - -func (e errInvalidAuthKeys) Error() string { - return "Invalid authorization keys" -} -*/ - type errInvalidSource struct { URL string } @@ -124,3 +106,11 @@ type errInvalidTarget struct { func (e errInvalidTarget) Error() string { return "Invalid target " + e.URL } + +type errInvalidTheme struct { + Theme string +} + +func (e errInvalidTheme) Error() string { + return "Theme " + e.Theme + " is not supported." +} diff --git a/main.go b/main.go index 665aad62..837eeeba 100644 --- a/main.go +++ b/main.go @@ -69,10 +69,7 @@ func getSystemData() map[string]string { pb.FormatBytes(int64(memstats.TotalAlloc)), pb.FormatBytes(int64(memstats.HeapAlloc)), pb.FormatBytes(int64(memstats.HeapSys))) - platform := fmt.Sprintf("Host: %s | OS: %s | Arch: %s", - host, - runtime.GOOS, - runtime.GOARCH) + platform := fmt.Sprintf("Host: %s | OS: %s | Arch: %s", host, runtime.GOOS, runtime.GOARCH) goruntime := fmt.Sprintf("Version: %s | CPUs: %s", runtime.Version(), strconv.Itoa(runtime.NumCPU())) return map[string]string{ "PLATFORM": platform, @@ -122,17 +119,20 @@ func main() { themeName := ctx.GlobalString("theme") switch { case console.IsValidTheme(themeName) != true: - console.Fatals(ErrorMessage{ + err := iodine.New(errInvalidTheme{Theme: themeName}, nil) + console.Errors(ErrorMessage{ Message: fmt.Sprintf("Please choose from this list: %s.", console.GetThemeNames()), - Error: fmt.Errorf("Theme ā€˜%s’ is not supported.", themeName), + Error: err, }) + return err default: err := console.SetTheme(themeName) if err != nil { - console.Fatals(ErrorMessage{ + console.Errors(ErrorMessage{ Message: fmt.Sprintf("Failed to set theme ā€˜%s’.", themeName), Error: err, }) + return err } } checkConfig()