first mvp

This commit is contained in:
2026-05-16 01:39:45 +08:00
parent b3a2ae4681
commit 69afb0a53e
13 changed files with 205 additions and 272 deletions
+10 -18
View File
@@ -6,33 +6,25 @@ import (
"gopkg.in/yaml.v3"
)
// Config 定义 cliprepo 的配置结构
//
// 当前支持的配置:
// Bundles:用于定义一组文件路径集合
// key -> bundle 名称
// value -> 对应的文件路径列表
type Config struct {
Bundles map[string][]string `yaml:"bundles"`
Config struct {
PathMode string `yaml:"path_mode"`
} `yaml:"config"`
Prompts struct {
Preset string `yaml:"preset"`
} `yaml:"prompts"`
Preset map[string][]string `yaml:"preset"`
}
// Load 从项目根目录读取 cliprepo.yaml 配置文件,并解析为 Config 结构
//
// 行为说明:
// 1. 默认读取当前工作目录下的 cliprepo.yaml
// 2. 如果文件不存在或读取失败,直接返回 error
// 3. 使用 YAML 解析配置内容到 Config 结构体
func Load() (*Config, error) {
// 读取配置文件内容
data, err := os.ReadFile("cliprepo.yaml")
data, err := os.ReadFile(".cliprepo.yaml")
if err != nil {
return nil, err
}
var cfg Config
// 解析 YAML 到结构体
err = yaml.Unmarshal(data, &cfg)
return &cfg, err
}