Add errInvalidTheme and .Before should reply back to cli as error

This commit is contained in:
Harshavardhana
2015-06-11 14:36:35 -07:00
parent 0f14199a2b
commit dae79df316
4 changed files with 17 additions and 28 deletions
+2 -2
View File
@@ -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",
-1
View File
@@ -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)
}
}
+8 -18
View File
@@ -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."
}
+7 -7
View File
@@ -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()