1
0
mirror of https://github.com/writeas/writeas-cli synced 2025-07-26 23:08:16 +00:00
writeas-cli/config/fonts.go

47 lines
1.0 KiB
Go
Raw Normal View History

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
func GetFont(code bool, font string) string {
2015-11-10 00:48:28 +00:00
if code {
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"
}
// Validate font value
if f, ok := postFontMap[font]; ok {
return string(f)
}
fmt.Printf("Font '%s' invalid. Using default '%s'\n", font, DefaultFont)
return string(DefaultFont)
2015-11-10 00:48:28 +00:00
}