Possible fix for SetTheme issue

This commit is contained in:
Harshavardhana
2015-08-12 12:48:00 -07:00
parent 03542acc1d
commit 40d096353d
2 changed files with 49 additions and 7 deletions
+1
View File
@@ -88,6 +88,7 @@ func registerBefore(ctx *cli.Context) error {
console.Errorf("Invalid theme, please choose from the following list: %s.\n", console.GetThemeNames())
return errInvalidTheme{Theme: themeName}
}
if err := console.SetTheme(themeName); err != nil {
console.Errorf("Failed to set theme ‘%s’.", themeName)
errorIf(err)
+48 -7
View File
@@ -209,19 +209,60 @@ var (
}
// Time helper to print Time theme
Time = themesDB[currThemeName].Time.SprintfFunc()
Time = func(format string, data ...interface{}) string {
if isatty.IsTerminal(os.Stdout.Fd()) {
return themesDB[currThemeName].Time.SprintfFunc()(format, data...)
}
return fmt.Sprintf(format, data...)
}
// Size helper to print Size theme
Size = themesDB[currThemeName].Size.SprintfFunc()
Size = func(format string, data ...interface{}) string {
if isatty.IsTerminal(os.Stdout.Fd()) {
return themesDB[currThemeName].Size.SprintfFunc()(format, data...)
}
return fmt.Sprintf(format, data...)
}
// File helper to print File theme
File = themesDB[currThemeName].File.SprintfFunc()
File = func(format string, data ...interface{}) string {
if isatty.IsTerminal(os.Stdout.Fd()) {
return themesDB[currThemeName].File.SprintfFunc()(format, data...)
}
return fmt.Sprintf(format, data...)
}
// Dir helper to print Dir theme
Dir = themesDB[currThemeName].Dir.SprintfFunc()
Dir = func(format string, data ...interface{}) string {
if isatty.IsTerminal(os.Stdout.Fd()) {
return themesDB[currThemeName].Dir.SprintfFunc()(format, data...)
}
return fmt.Sprintf(format, data...)
}
// Command helper to print command theme
Command = themesDB[currThemeName].Command.SprintfFunc()
Command = func(format string, data ...interface{}) string {
if isatty.IsTerminal(os.Stdout.Fd()) {
return themesDB[currThemeName].Command.SprintfFunc()(format, data...)
}
return fmt.Sprintf(format, data...)
}
// SessionID helper to print sessionid theme
SessionID = themesDB[currThemeName].SessionID.SprintfFunc()
SessionID = func(format string, data ...interface{}) string {
if isatty.IsTerminal(os.Stdout.Fd()) {
return themesDB[currThemeName].SessionID.SprintfFunc()(format, data...)
}
return fmt.Sprintf(format, data...)
}
// JSON helper to print json strings
JSON = themesDB[currThemeName].JSON.SprintfFunc()
JSON = func(format string, data ...interface{}) string {
if isatty.IsTerminal(os.Stdout.Fd()) {
return themesDB[currThemeName].JSON.SprintfFunc()(format, data...)
}
return fmt.Sprintf(format, data...)
}
)
var (