1
0
mirror of https://github.com/writeas/writeas-cli synced 2025-07-26 23:08:16 +00:00
writeas-cli/config/fonts.go
Rob Loranger f227faa5dc
Closes T592 T593 T597 splits code into packages
this splits everything out into shared packages

- user config and application config share a package for now
- sync is part of the api package which includes the client, posts and
tor logic
- logging is it's own package
- commands are in their own package
2019-05-29 11:43:00 -07:00

47 lines
1.0 KiB
Go

package config
import (
"fmt"
)
// 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,
}
func GetFont(code bool, font string) string {
if code {
if font != "" && font != DefaultFont {
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)
}