Documentation
¶
Index ¶
- Constants
- Variables
- func ConfigCategoryIconMap(gameCode string) []markxus.CategoryIconMap
- func ConfigPath(configType ConfigType) string
- func CreateDefaultConfig() map[string]any
- func EnvToYaml(key string) string
- func Resolve(envKey string) any
- func ResolveFromYaml(configType ConfigType, yamlKey string) any
- func SetKeyring(key string, value string) error
- func YamlToEnv(key string) string
- type ConfigType
- type EnumValue
- type KV
- type MarkxusConfig
Constants ¶
View Source
const Version = "v0.1.6"
Variables ¶
View Source
var ( YamlKeyGenAiApiKey = "genai_api_key" YamlKeyGenAiModelName = "genai_model_name" YamlKeyMarkxusPromptFormat = "genai_prompt_format" YamlKeyNexusApiKey = "nexus_api_key" YamlKeyNexusUrlGetModFormat = "nexus_url_get_mod_format" YamlKeyMarkxusUrlModPageFormat = "nexus_url_mod_page_format" YamlKeyMarkdownHeaderFormat = "markdown_header_format" YamlKeyFallbackGameCode = "fallback_game_code" YamlKeyOutputDir = "output_dir" YamlKeyOverwriteOutput = "overwrite_output" YamlKeyCategoryIconMap = "category_icon_map" )
View Source
var ( EnvKeyGenAiApiKey = "GEN_AI_API_KEY" EnvKeyGenAiModelName = "GEN_AI_MODEL_NAME" EnvKeyMarkxusPromptFormat = "GEN_AI_PROMPT_FORMAT" EnvKeyNexusApiKey = "NEXUS_API_KEY" EnvKeyNexusUrlGetModFormat = "NEXUS_URL_GET_MOD_FORMAT" EnvKeyMarkxusUrlModPageFormat = "NEXUS_URL_MOD_PAGE_FORMAT" EnvKeyMarkdownHeaderFormat = "MARKDOWN_HEADER_FORMAT" EnvKeyFallbackGameCode = "FALLBACK_GAME_CODE" EnvKeyOutputDir = "OUTPUT_DIR" EnvKeyOverwriteOutput = "OVERWRITE_OUTPUT" )
View Source
var ( GenAICategory = "GenAI" FlagGenAiApiKey = &cli.StringFlag{ Name: "genai-key", Aliases: []string{"gk"}, Destination: &Config.GenAi.ApiKey, Category: GenAICategory, Required: true, Usage: "API key to be used for generative ai requests", Sources: cli.NewValueSourceChain( cli.EnvVar(EnvKeyGenAiApiKey), cli.NewMapValueSource(YamlKeyGenAiApiKey, YamlSourceLocal), cli.NewMapValueSource(YamlKeyGenAiApiKey, YamlSourceGlobal), cli.NewMapValueSource(YamlKeyGenAiApiKey, KeyringSource), ), } FlagGenAiModelName = &cli.StringFlag{ Name: "model", Aliases: []string{"m"}, Destination: &Config.GenAi.ModelName, Category: GenAICategory, DefaultText: genai.DefaultModelName, Usage: "Model name to be used for generative ai requests", Value: genai.DefaultModelName, Sources: cli.NewValueSourceChain( cli.EnvVar(EnvKeyGenAiModelName), cli.NewMapValueSource(YamlKeyGenAiModelName, YamlSourceLocal), cli.NewMapValueSource(YamlKeyGenAiModelName, YamlSourceGlobal), ), } FlagMarkxusPromptFormat = &cli.StringFlag{ Name: "prompt", Aliases: []string{"p"}, Destination: &Config.GenAi.Prompt, Category: GenAICategory, DefaultText: "[[DefaultGenAiPromptFormat]]", Usage: "Prompt format to be used for generative ai requests", Value: markxus.DefaultGenAiPromptFormat, Sources: cli.NewValueSourceChain( cli.EnvVar(EnvKeyMarkxusPromptFormat), cli.NewMapValueSource(YamlKeyMarkxusPromptFormat, YamlSourceLocal), cli.NewMapValueSource(YamlKeyMarkxusPromptFormat, YamlSourceGlobal), ), } )
View Source
var ( NexusCategory = "Nexus" FlagNexusApiKey = &cli.StringFlag{ Name: "nexus-key", Aliases: []string{"nk"}, Destination: &Config.Nexus.ApiKey, Category: "Nexus", Required: true, Usage: "API key to be used for nexus requests", Sources: cli.NewValueSourceChain( cli.EnvVar(EnvKeyNexusApiKey), cli.NewMapValueSource(YamlKeyNexusApiKey, YamlSourceLocal), cli.NewMapValueSource(YamlKeyGenAiApiKey, YamlSourceGlobal), cli.NewMapValueSource(YamlKeyNexusApiKey, KeyringSource), ), } FlagNexusUrlGetModFormat = &cli.StringFlag{ Name: "api-url-format", Aliases: []string{"af"}, Destination: &Config.Nexus.Url.GetModFormat, Category: "Nexus", DefaultText: nexus.DefaultUrlGetModFormat, Usage: "URL format to be for mod data API", Value: nexus.DefaultUrlGetModFormat, Sources: cli.NewValueSourceChain( cli.EnvVar(EnvKeyNexusUrlGetModFormat), cli.NewMapValueSource(YamlKeyNexusUrlGetModFormat, YamlSourceLocal), cli.NewMapValueSource(YamlKeyNexusUrlGetModFormat, YamlSourceGlobal), ), } FlagMarkxusUrlModPageFormat = &cli.StringFlag{ Name: "page-url-format", Aliases: []string{"pf"}, Destination: &Config.Nexus.Url.ModPageFormat, Category: "Nexus", DefaultText: markxus.DefaultUrlModPageFormat, Usage: "URL format to be for mod page", Value: markxus.DefaultUrlModPageFormat, Sources: cli.NewValueSourceChain( cli.EnvVar(EnvKeyMarkxusUrlModPageFormat), cli.NewMapValueSource(YamlKeyMarkxusUrlModPageFormat, YamlSourceLocal), cli.NewMapValueSource(YamlKeyMarkxusUrlModPageFormat, YamlSourceGlobal), ), } )
View Source
var ( GenerationCategory = "Markdown" FlagMarkdownHeaderFormat = &cli.StringFlag{ Name: "header-format", Aliases: []string{"hf"}, Destination: &Config.Generation.HeaderFormat, Category: GenerationCategory, DefaultText: "[[DefaultMarkdownHeaderFormat]]", Usage: "Template to be used for markdown header", Value: markxus.DefaultMarkdownHeaderFormat, Sources: cli.NewValueSourceChain( cli.EnvVar(EnvKeyMarkdownHeaderFormat), cli.NewMapValueSource(YamlKeyMarkdownHeaderFormat, YamlSourceLocal), cli.NewMapValueSource(YamlKeyMarkdownHeaderFormat, YamlSourceGlobal), ), } FlagOutputDir = &cli.StringFlag{ Name: "output-dir", Aliases: []string{"outdir", "o"}, Destination: &Config.Generation.OutputDir, Category: GenerationCategory, Usage: "Output directory for markdown files", Value: ".", Sources: cli.NewValueSourceChain( cli.EnvVar(EnvKeyOutputDir), cli.NewMapValueSource(YamlKeyOutputDir, YamlSourceLocal), cli.NewMapValueSource(YamlKeyOutputDir, YamlSourceGlobal), ), } )
View Source
var ( HelperCategory = "Helper" FlagFallbackGameCode = &cli.StringFlag{ Name: "game-code", Aliases: []string{"gc"}, Destination: &Config.Helper.FallbackGameCode, Category: HelperCategory, Usage: "Fallback game code to use when no game code supplied in args", Sources: cli.NewValueSourceChain( cli.EnvVar(EnvKeyFallbackGameCode), cli.NewMapValueSource(YamlKeyFallbackGameCode, YamlSourceLocal), cli.NewMapValueSource(YamlKeyFallbackGameCode, YamlSourceGlobal), ), } )
View Source
var ( FlagOverwriteOutput = &cli.BoolFlag{ Name: "overwrite", Aliases: []string{"w"}, Usage: "Overwrite existing markdown if exist", Value: false, Destination: &Config.Common.Overwrite, Sources: cli.NewValueSourceChain( cli.EnvVar(EnvKeyOverwriteOutput), cli.NewMapValueSource(YamlKeyOverwriteOutput, YamlSourceLocal), cli.NewMapValueSource(YamlKeyOverwriteOutput, YamlSourceGlobal), ), } FlagConfigType = &cli.GenericFlag{ Name: "type", Aliases: []string{"t"}, Usage: "Config type to be used, either global or local", DefaultText: "global", Value: &Config.Common.ConfigType, Sources: cli.NewValueSourceChain( cli.EnvVar("CONFIG_TYPE"), ), } )
View Source
var AllFlags = []cli.Flag{ FlagGenAiApiKey, FlagGenAiModelName, FlagMarkxusPromptFormat, FlagNexusApiKey, FlagNexusUrlGetModFormat, FlagMarkxusUrlModPageFormat, FlagMarkdownHeaderFormat, FlagFallbackGameCode, FlagOverwriteOutput, FlagConfigType, }
View Source
var ConfigPathGlobal = (func() string { home, err := os.UserHomeDir() if err != nil { panic(err) } return path.Join(home, ".markxus.yml") })()
View Source
var ConfigPathLocal = (func() string { cwd, err := os.Getwd() if err != nil { panic(err) } return path.Join(cwd, ".markxus.yml") })()
View Source
var KeyringSource = &keyringSource{}
View Source
var YamlSourceGlobal, YamlSourceGlobalError = NewYamlSource(ConfigPathGlobal)
View Source
var YamlSourceLocal, YamlSourceLocalError = NewYamlSource(ConfigPathLocal)
Functions ¶
func ConfigCategoryIconMap ¶
func ConfigCategoryIconMap(gameCode string) []markxus.CategoryIconMap
func ConfigPath ¶
func ConfigPath(configType ConfigType) string
func CreateDefaultConfig ¶
func ResolveFromYaml ¶
func ResolveFromYaml(configType ConfigType, yamlKey string) any
func SetKeyring ¶
Types ¶
type ConfigType ¶
type ConfigType string
var ( ConfigTypeGlobal ConfigType = "global" ConfigTypeLocal ConfigType = "local" )
type EnumValue ¶
type EnumValue[T ~string] struct { Enum []T Default T // contains filtered or unexported fields }
type KV ¶
func NewYamlSource ¶
type MarkxusConfig ¶
type MarkxusConfig struct {
GenAi struct {
ApiKey string
ModelName string
Prompt string
}
Nexus struct {
ApiKey string
Url struct {
GetModFormat string
ModPageFormat string
}
}
Generation struct {
HeaderFormat string
OutputDir string
}
Helper struct {
FallbackGameCode string
Interactive bool
}
Common struct {
ConfigType EnumValue[ConfigType]
Overwrite bool
}
}
var Config MarkxusConfig
Click to show internal directories.
Click to hide internal directories.