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

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
47 lines
1.0 KiB
Go
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)
|
|
}
|