2019-05-28 17:44:50 +00:00
|
|
|
package config
|
2015-11-02 02:24:34 +00:00
|
|
|
|
2015-11-10 00:48:28 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
2015-11-02 02:24:34 +00:00
|
|
|
// postFont represents a valid post appearance value in the API.
|
|
|
|
type postFont string
|
|
|
|
|
|
|
|
// Valid appearance types for posts.
|
|
|
|
const (
|
|
|
|
PostFontNormal postFont = "norm"
|
|
|
|
PostFontSans = "sans"
|
|
|
|
PostFontMono = "mono"
|
|
|
|
PostFontWrap = "wrap"
|
|
|
|
PostFontCode = "code"
|
|
|
|
)
|
|
|
|
|
|
|
|
var postFontMap = map[string]postFont{
|
|
|
|
"norm": PostFontNormal,
|
|
|
|
"normal": PostFontNormal,
|
|
|
|
"serif": PostFontNormal,
|
|
|
|
"sans": PostFontSans,
|
|
|
|
"sansserif": PostFontSans,
|
|
|
|
"mono": PostFontMono,
|
|
|
|
"monospace": PostFontMono,
|
|
|
|
"wrap": PostFontWrap,
|
|
|
|
"code": PostFontCode,
|
|
|
|
}
|
2015-11-10 00:48:28 +00:00
|
|
|
|
2019-05-28 17:44:50 +00:00
|
|
|
func GetFont(code bool, font string) string {
|
2015-11-10 00:48:28 +00:00
|
|
|
if code {
|
2019-05-28 00:18:45 +00:00
|
|
|
if font != "" && font != DefaultFont {
|
2015-11-10 00:48:28 +00:00
|
|
|
fmt.Printf("A non-default font '%s' and --code flag given. 'code' type takes precedence.\n", font)
|
|
|
|
}
|
|
|
|
return "code"
|
|
|
|
}
|
2016-03-16 20:33:35 +00:00
|
|
|
|
|
|
|
// Validate font value
|
|
|
|
if f, ok := postFontMap[font]; ok {
|
|
|
|
return string(f)
|
|
|
|
}
|
|
|
|
|
2019-05-28 00:18:45 +00:00
|
|
|
fmt.Printf("Font '%s' invalid. Using default '%s'\n", font, DefaultFont)
|
|
|
|
return string(DefaultFont)
|
2015-11-10 00:48:28 +00:00
|
|
|
}
|