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
- type Provider
Constants ¶
View Source
const Version = "v0.2.1"
Variables ¶
View Source
var ( YamlKeyLlmProvider = "llm_provider" YamlKeyLlmApiKey = "llm_api_key" YamlKeyLlmModelName = "llm_model_name" YamlKeyMarkxusPromptFormat = "llm_prompt_format" YamlKeyNexusApiKey = "nexus_api_key" YamlKeyNexusUrlGetModFormat = "nexus_url_get_mod_format" YamlKeyNexusUrlGetFilesFormat = "nexus_url_get_files_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 ( EnvKeyLlmProvider = "LLM_PROVIDER" EnvKeyLlmApiKey = "LLM_API_KEY" EnvKeyLlmModelName = "LLM_MODEL_NAME" EnvKeyMarkxusPromptFormat = "LLM_PROMPT_FORMAT" EnvKeyNexusApiKey = "NEXUS_API_KEY" EnvKeyNexusUrlGetModFormat = "NEXUS_URL_GET_MOD_FORMAT" EnvKeyNexusUrlGetFilesFormat = "NEXUS_URL_GET_FILES_FORMAT" EnvKeyMarkxusUrlModPageFormat = "NEXUS_URL_MOD_PAGE_FORMAT" EnvKeyMarkdownHeaderFormat = "MARKDOWN_HEADER_FORMAT" EnvKeyFallbackGameCode = "FALLBACK_GAME_CODE" EnvKeyOutputDir = "OUTPUT_DIR" EnvKeyOverwriteOutput = "OVERWRITE_OUTPUT" )
View Source
var ( LLMCategory = "LLM" FlagLlmProvider = &cli.GenericFlag{ Name: "llm-provider", Aliases: []string{"gp"}, Usage: "LLM provider to be used, either from OpenAI (open_ai) or Google Generative AI (gen_ai)", DefaultText: "global", Category: LLMCategory, Value: &Config.Llm.Provider, Sources: cli.NewValueSourceChain( cli.EnvVar(EnvKeyLlmProvider), cli.NewMapValueSource(YamlKeyLlmProvider, YamlSourceLocal), cli.NewMapValueSource(YamlKeyLlmProvider, YamlSourceGlobal), ), } FlagLlmApiKey = &cli.StringFlag{ Name: "llm-key", Aliases: []string{"gk"}, Destination: &Config.Llm.ApiKey, Category: LLMCategory, Required: true, Usage: "API key to be used for AI generation", Sources: cli.NewValueSourceChain( cli.EnvVar(EnvKeyLlmApiKey), cli.NewMapValueSource(YamlKeyLlmApiKey, YamlSourceLocal), cli.NewMapValueSource(YamlKeyLlmApiKey, YamlSourceGlobal), cli.NewMapValueSource(YamlKeyLlmApiKey, KeyringSource), ), } FlagLlmModelName = &cli.StringFlag{ Name: "model", Aliases: []string{"m"}, Destination: &Config.Llm.ModelName, Category: LLMCategory, DefaultText: genai.DefaultModelName, Usage: "Model name to be used for AI generation", Value: genai.DefaultModelName, Sources: cli.NewValueSourceChain( cli.EnvVar(EnvKeyLlmModelName), cli.NewMapValueSource(YamlKeyLlmModelName, YamlSourceLocal), cli.NewMapValueSource(YamlKeyLlmModelName, YamlSourceGlobal), ), } FlagMarkxusPromptFormat = &cli.StringFlag{ Name: "prompt", Aliases: []string{"p"}, Destination: &Config.Llm.Prompt, Category: LLMCategory, DefaultText: "[[DefaultLlmPromptFormat]]", Usage: "Prompt format to be used for AI generation", Value: markxus.DefaultLlmPromptFormat, 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(YamlKeyNexusApiKey, YamlSourceGlobal), cli.NewMapValueSource(YamlKeyNexusApiKey, KeyringSource), ), } FlagNexusUrlGetModFormat = &cli.StringFlag{ Name: "api-mod-url-format", Aliases: []string{"am"}, Destination: &Config.Nexus.Url.GetModFormat, Category: "Nexus", DefaultText: nexus.DefaultUrlGetModFormat, Usage: "URL format for mod data API", Value: nexus.DefaultUrlGetModFormat, Sources: cli.NewValueSourceChain( cli.EnvVar(EnvKeyNexusUrlGetModFormat), cli.NewMapValueSource(YamlKeyNexusUrlGetModFormat, YamlSourceLocal), cli.NewMapValueSource(YamlKeyNexusUrlGetModFormat, YamlSourceGlobal), ), } FlagNexusUrlGetModFilesFormat = &cli.StringFlag{ Name: "api-files-url-format", Aliases: []string{"af"}, Destination: &Config.Nexus.Url.GetFilesFormat, Category: "Nexus", DefaultText: nexus.DefaultUrlGetFilesFormat, Usage: "URL format for mod files data API", Value: nexus.DefaultUrlGetFilesFormat, Sources: cli.NewValueSourceChain( cli.EnvVar(EnvKeyNexusUrlGetFilesFormat), cli.NewMapValueSource(YamlKeyNexusUrlGetFilesFormat, YamlSourceLocal), cli.NewMapValueSource(YamlKeyNexusUrlGetFilesFormat, 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{ FlagLlmApiKey, FlagLlmModelName, 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 {
Llm struct {
Provider EnumValue[Provider]
ApiKey string
ModelName string
Prompt string
}
Nexus struct {
ApiKey string
Url struct {
GetModFormat string
GetFilesFormat 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.